Delete Build Folder

Hello Guys,

Is there a way to Delete the Builds folder before Build ? as most often and since El Capitan I guess, the Built app does not override anymore and I always have to enter to builds folder and delete the app in order to be able to build new one .

I found this code on the forum for Debug files , I adapt it but unfortunately does not work and it seems that I cannot debug the scripts to see where is wrong .

[code]
Dim pa() As String = Split(ProjectShellPath,"/")
pa.Remove(UBound(pa))
Dim ProjectFolder As String = Join(pa,"/")

Dim BuildAppName As String = PropertyValue(“App.MacOSXAppName”)

BuildAppName = Replace(BuildAppName,".app","") + “.xojo_project”
Dim BuildsFolder As String = ProjectFolder + “/Builds - " + BuildAppName
BuildsFolder = Replace(BuildsFolder,” “,”\ ")

Dim cmd As String

cmd = "rm -rf " + BuildsFolder

Call DoShellCommand(cmd)[/code]

Any other Ideas ? I have multiple projects and I need some automation to skip the manual delete step.

Thanks .

What version of Xojo are you using? I believe they fixed the sticky builds issue recently (2017 or 2018)

Hi Tim , latest public OS and 2018R2

What doesn’t work? The files aren’t deleted?

Why can’t you debug the script? Here is my script:

[code]‘kill app if running
dim theCommand as String
theCommand = “ps -axwwopid,command | grep '” + PropertyValue(“App.MacOSXAppName”) +"’ | grep -v grep | awk ‘{print $1}’"
dim theResult as String
theResult = DoShellCommand(theCommand)
if theResult <> “” then
theCommand = "kill " + theResult
theResult = DoShellCommand(theCommand)
end if

'get path and app name
dim appNameForShell as string = PropertyValue(“App.MacOSXAppName”) + “.debug.app”
appNameForShell = getShellString(appNameForShell)
dim CountSlashes as Integer = CountFields(ProjectShellPath, “/”)
dim ProjectName as string = NthField(ProjectShellPath, “/”, CountSlashes)
dim ProjectPath as String = Left(ProjectShellPath, Len(ProjectShellPath) - Len(ProjectName))

'delete app
theCommand = "rm -rf " + ProjectPath + appNameForShell
theResult = DoShellCommand(theCommand)
if theResult <> “” then print theResult

function getShellString(theString as String) as string
Return ReplaceAll(theString, " ", "\ ")
end Function[/code]

[quote=406321:@Beatrix Willius]What doesn’t work? The files aren’t deleted?

Why can’t you debug the script? Here is my script:

[code]‘kill app if running
dim theCommand as String
theCommand = “ps -axwwopid,command | grep '” + PropertyValue(“App.MacOSXAppName”) +"’ | grep -v grep | awk ‘{print $1}’"
dim theResult as String
theResult = DoShellCommand(theCommand)
if theResult <> “” then
theCommand = "kill " + theResult
theResult = DoShellCommand(theCommand)
end if

'get path and app name
dim appNameForShell as string = PropertyValue(“App.MacOSXAppName”) + “.debug.app”
appNameForShell = getShellString(appNameForShell)
dim CountSlashes as Integer = CountFields(ProjectShellPath, “/”)
dim ProjectName as string = NthField(ProjectShellPath, “/”, CountSlashes)
dim ProjectPath as String = Left(ProjectShellPath, Len(ProjectShellPath) - Len(ProjectName))

'delete app
theCommand = "rm -rf " + ProjectPath + appNameForShell
theResult = DoShellCommand(theCommand)
if theResult <> “” then print theResult

function getShellString(theString as String) as string
Return ReplaceAll(theString, " ", "\ ")
end Function[/code][/quote]
Cool, it works with your script, I wish XOJO could handle those automatically but I guess I will have to add 2 scripts on each project before Build part.

Thanks again.

In the last 2017 version I tracked my problem down to the app icon files… No icon => No problem. So now I only add the icon when I’m building a verson for release.

I tried this and it’s not working. This is an annoying issue I wasn’t having this issue two weeks ago. I have a MAC all the latest updates. I did just rebuild my machine this week. but still the same OS code. Are we sure the is O/S related.

Yes. The deletion fails, usually, because Icon Services is hanging on to the icon file. You can see this is the case if you open Terminal on the Mac and enter:

lsof +D

This is almost the same issue:
https://forum.xojo.com/41689-debug-file-not-getting-deleted

We believe we have this fixed in an upcoming release.

Jason,

thanks for the update looking forward to the fix. I did not specify an icon for my app so should this still apply?

Hi Michael - It’s usually the icon that has been at issue. However, it’s not the only one that we’ve seen the OS hang onto and not allow us to delete. The LSOF command mentioned above will tell you which file & what process is holding that file busy so it cannot be deleted.

Here are the before and after states. The application is called Postal.

lsof output while the app is running

COMMAND     PID       USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
Path\\x20F   494 momiccioli   89r   DIR    1,4      256  963727 .
Path\\x20F   494 momiccioli   90r   DIR    1,4      256  963729 ./DebugPostal
bash       5963 momiccioli  cwd    DIR    1,4      256  963727 .
mdworker  47750 momiccioli    3r   REG    1,4     6148  963728 ./.DS_Store
mdworker  47751 momiccioli    3r   REG    1,4     6148  963728 ./.DS_Store
mdworker  47753 momiccioli    3r   REG    1,4     6148  963728 ./.DS_Store
Postal.de 47861 momiccioli  txt    REG    1,4  3446488 2292665 ./Postal.debug.app/Contents/MacOS/Postal.debug
Postal.de 47861 momiccioli  txt    REG    1,4 11887744 2292679 ./Postal.debug.app/Contents/Frameworks/XojoFramework.framework/Versions/A/XojoFramework
Postal.de 47861 momiccioli  txt    REG    1,4   439104 2292848 ./Postal.debug.app/Contents/Frameworks/Crypto.dylib
Postal.de 47861 momiccioli  txt    REG    1,4    22480 2292849 ./Postal.debug.app/Contents/Frameworks/InternetEncodings.dylib
Postal.de 47861 momiccioli  txt    REG    1,4    32896 2292850 ./Postal.debug.app/Contents/Frameworks/Shell.dylib
Postal.de 47861 momiccioli  txt    REG    1,4   893552 2292851 ./Postal.debug.app/Contents/Frameworks/SQLiteDatabase.dylib
Postal.de 47861 momiccioli  txt    REG    1,4  1807088 2292852 ./Postal.debug.app/Contents/Frameworks/SSLSocket.dylib
sudo      47942       root  cwd    DIR    1,4      256  963727 .
lsof      47944       root  cwd    DIR    1,4      256  963727 .
lsof      47945       root  cwd    DIR    1,4      256  963727 .

lsof output after app is closed

COMMAND     PID       USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
Path\\x20F   494 momiccioli   89r   DIR    1,4      256 963727 .
Path\\x20F   494 momiccioli   90r   DIR    1,4      256 963729 ./DebugPostal
bash       5963 momiccioli  cwd    DIR    1,4      256 963727 .
mdworker  47750 momiccioli    3r   REG    1,4     6148 963728 ./.DS_Store
mdworker  47751 momiccioli    3r   REG    1,4     6148 963728 ./.DS_Store
mdworker  47753 momiccioli    3r   REG    1,4     6148 963728 ./.DS_Store
sudo      47955       root  cwd    DIR    1,4      256 963727 .
lsof      47956       root  cwd    DIR    1,4      256 963727 .
lsof      47957       root  cwd    DIR    1,4      256 963727 .

The file that is preventing the application from running again is Postal.debug.app. Interestingly it does not show up in the lsof after exiting the app. I do see the directory DebugPostal is listed but not the application file.

Am I reading this incorrectly?

In the after run see those mdworker ones? Those are system processes sill holding files busy and that means they can’t be deleted and … you get the problem you’re seeing.

We do, however, believe we have solved this for the future.

Just to mention that while the script works on the local, using another script that works on local on debug time fails always while using Remote Debugger

[code]// Get the path of the project and strip off the project name
Dim pa() As String = Split(ProjectShellPath,"/")
pa.Remove(UBound(pa))
Dim ProjectFolder As String = Join(pa,"/")

// Get the app’s name from the IDE
Dim DebugAppName As String = PropertyValue(“App.MacOSXAppName”)

// Strip off .app if it’s there and append “.debug.app”
DebugAppName = Replace(DebugAppName,".app","") + “.debug.app”

// Escape spaces in the name
DebugAppName = Replace(DebugAppName," “,”\ ")

// Make the full path
Dim AppPath As String = ProjectFolder + “/” + DebugAppName

// Make the remove command
Dim cmd As String = "rm -rf " + AppPath

// Execute it
Call DoShellCommand(cmd)
[/code]

Maybe that helps and will be fixed as well.

Thanks again .

No matter what I try the script does not run. If I delete the debug executable then run, the script will then run. I confirmed this by putting a print statement in. So it appears that the debug script does not run until the debug executable is created.

Is there a setting that needs to changed or implemented to get the script to run prior to compilation?

Update,

I indicated earlier that two weeks ago all was fine and no issues with Xojo. Last weekend I rebuilt my Mac Book Pro and restored most of my system from backup including the Xojo IDE. Since then I have had this issue with the debug file not being deleted and Xojo itself was unstable.

I decided to delete the Xojo IDE and reinstall fresh. After a fresh install all is right again. I can run applications repeatedly with needing to manually delete the debug file. And I am not running a debug script either. Here are the details of my machine

macOS High Sierra
Version 10.13.6
Xojo 2018 R2

So it turns out all my issues relate to dirty restore.

We’ll it’s hectic here, some times is working some times not, no idea why and how, so far the new code was working well and today even that code does not work anymore, I guess I’ll try to do like Michael and Reinstall all clean and see if I get same issue as this is crazy.

I’m still having one issue but not sure it’s Xojo’s fault. I have an application that displays a one page PDF. After my rebuild when I run the app this first time I try to display a pdf, I get prompted to select a browser. I point to the Adobe Pro executable and then the file displays. I don’t get prompted again for the executable until the app is terminated and restarted. There have been no changes to the Xojo Code for the app I wrote. This was not happening prior to the rebuild and I am using the same versions.

I did do a clean install of Adobe but something is not right, hopefully there are some hints from others here. Again this was working before the rebuild and I don’t think it’s a Xojo issue. FYI, I use the HTML Viewer to display the PDFs.

Thoughts anyone?