PDA

View Full Version : Change output [EXENAME] dynamically



CleanFacets
09-06-2017, 11:41 AM
We need to automatically assign the output executable to include a version within the filename.
For example: compile the .sbp and generate Setup001.exe. Then when we have a new version run the compiler again and generate Setup002.exe.

I added the ability to call a dll which generates a new filename with the version embeded in it where my local variable %NEWBUILDNAME% contains the characters 'Setup003.exe'

Then, use that variable to assign it to [EXENAME] so the compiler generates a dynamically named setup file.
If my outputdir was C:\Temp\ and [EXENAME] was set to %NEWBUILDNAME%, the filename ends up being:
C:\Temp\%NEWBUILDNAME instead of using the value within the variable.

I have even tried #copy and #rename set with Process After Script Compilation and it is the same result.

Thanks in advance.
Carl

linder
09-07-2017, 05:07 AM
Carl,

my first idea was to use this built-in feature:

http://www.lindersoft.com/forums/showthread.php?46916-SB10-Tips-amp-Tricks-3-Automating-Version-and-Build-Numbers

But you are not using a "standard" version numbering format, so this can't be used here. It would create "Setup0.0.0.2.exe" instead of your "Setup002.exe" format.

Here is another possible method, but it does not fit your needs:

http://www.lindersoft.com/forums/showthread.php?47608-Use-value-from-version-resource-file-as-part-of-installer-name

By the way, your DLL technique did not work because %NEWBUILDNAME% is a runtime variable. This is only available when you run the setup.exe and is not valid when you compile a setup.exe.

I have developed a helper application with SetupBuilder for you. I have uploaded both the helper source code and the demo project to:

http://www.lindersoft.com/projects/AutoIncrementSetup.zip

The non-elevated running helper application ("increment.exe") is called from your main project and auto increments the build number when you compile the project. The last build number is stored in the "build.txt" ASCII text file.

See attached screenshots.

1. Add the Lines 16-18 from the "setup_build_demo.sbp" project file to your main project.

2. Set the "Executable Name [EXENAME]" in your main project (General Information -> Product Properties) to setup[MY_SETUP_BUILD].exe

3. Copy the "increment.exe" helper application to the same folder where your main project .sbp file is located.

4. Compile your project.

Does this help?

Friedrich

CleanFacets
09-07-2017, 10:48 AM
Thank you very much for the suggestions.
Since we use a resource file and set the File Version and Product Version for each build, it worked out perfectly to use the Value From Resouce example.

linder
09-07-2017, 12:21 PM
Perfect! Thanks for the update.

Friedrich