Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClickOnce deployment with MSBuild -> How to pass the current build number for application version/ or autoincrement

We have an Outlook add-in which is using ClickOnce deployment.

Once the developer check in the build, the PC queues a build and the application is published to a location on a shared drive.

The problem is that the build does not change the publish version to the current assembly version and therefore it publishes in the previous version's folder which results in a corrupted installer saying that the version cannot be installed.

I've read that article. And I set up [assembly: AssemblyVersion("1.0.*")]. Still nothing.

I figured out a way to work around this problem by incrementing the <ApplicationVersion></ApplicationVersion> in the *.csproj file. But I want it to be automated.

The other workaround was when executing msbuild.exe:

/target:publish   /property:PublishDir="\\sharedDir\\" /property:GenerateManifests=true
/property:ApplicationVersion=1.0.0.123

And still it is not automated. I really would like to pass the current build number either to the msbuild.exe or on every build replace the value in <ApplicationVersion></ApplicationVersion> with the actual build number. Or is there another way?

like image 695
Alexander Beninski Avatar asked May 07 '12 13:05

Alexander Beninski


1 Answers

I was running into the same problem which is how I got here. I was able to solve using the code from your question as a base. Here are the steps to solve using TFS.

Open your Build Template and open the Arguments tab at the bottom of the workflow. Find MSBuildArguments and modify the default value. Below is what I ended up with:

// Note: You can use /p for /property and /t for /target

"/t:Publish /p:PublishDir=<PublishDirectory> /p:ApplicationVersion="
    + Date.Today.ToString("yyyy") + "."
    + Date.Today.ToString("MMdd") + "."
    + Date.Now.Hour.ToString() + "."
    + Date.Now.Minute.ToString()

Of course now you need to save and check-in your new build file. I had problems getting my build definition to use the new value, so I just created a new build definition.

That will create a new Application folder like:

<ApplicationName>_2013_0315_09_55

I know this is a new answer to an old post, so I'm sure you've found another solution, but I hope this helps anyone else who wants to use ClickOnce deployment with TFS.

like image 144
Johnie Karr Avatar answered Sep 28 '22 06:09

Johnie Karr