PDA

View Full Version : save project programmatically


dawson
11-17-2003, 09:12 AM
Hello,

How can I save the build project programatically? I am incrementing the build number macro (which is contained in my build project file), but this file is also located in VSS. I need to increment the build number, save the build file, and then check the build file back in VSS.

I would think this should be fairly easy to do, as it is basically a neccessity for automated builds. (My build will be automated if that helps).

Thanks for any help,
Dawson

kinook
11-17-2003, 09:58 AM
See http://www.kinook.com/Forum/showthread.php?threadid=245

Although, you may want to consider storing the build number elsewhere. It is preferable to separate data (build number) and logic (the .bld project) when possible. If other changes are made to the project during the build session (for instance, temporarily unchecking a step) and they aren't changed back, those changes will also get saved, which may not be desirable.

One alternative would be to store the build number in a text file. Create a one line text file with the initial build number and add to source control. Then add a Set Macro step at the beginning of the build project to read the first line of the text file into a temporary macro (i.e., BUILD_NUM) by specifying a Value of:

[vbld_FSO().OpenTextFile("filename").ReadLine()]

then use %BUILD_NUM% to reference the build number from build steps; increment BUILD_NUM as usual, then use a Write File step of

%BUILD_NUM%

to write the incremented build number back out to the file. Check the text file in/out of source control as part of the build process. The .bld file only needs to be checked out when the project logic needs to be modified.