views:

138

answers:

1

I'm currently looking for a way to keep setup projects outputs from overwriting previous versions. I.E When a setup project is built, it replaces anything in Release/Debug folder, is there any way to rename the output to something including the version number, or date, just so it doesn't overwrite the previous file there, or even create individual folders for each build which include date and time.

I know this can be done wiht PostbuildEvents, but just can't get my head around what needs to be done.

By the way, this is visual Studio 2008.

+1  A: 

This was harder than I expected; the PostBuild event value does not expand deployment properties, and I could see no way to get an assembly version from the command line.

The solution I came up with was to create a PostBuild event that would copy the project output to a file name constructed using substring evaluation on the %DATE% and %TIME% environment variables to get a unique filename. Give this a try:

COPY "$(BuiltOuputPath)" "$(ProjectDir)YourProjectName%DATE:~-4%%DATE:~-10,2%%DATE:~-7,2%%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.msi"

Yes, it's spelled "BuiltOuputPath" with 3 "t"s. Thanks Microsoft!

Dour High Arch

related questions