Reputation: 817
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?
Upvotes: 5
Views: 7487
Reputation: 2822
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.
Upvotes: 6
Reputation: 2056
I use Hudson as a build server and MSBuild to do the build. Hudson sets an environment variable with the build number. I then pass that environment variable as a command line argument to a program I wrote that parses the assemlyinfo.cs
file and updates the assembly verison, file version and the assembly informational version.
An alternative approach would be to create a custom task to do this instead of an executable (Even easier now since it now supports inline tasks). The previous version of TFS did something similar where it set an enviornment variable, but it may have changed in TFS 2010.
Here are resources that may help you with that:
Also, we're using the Mage command line to create the ClickOnce application and deployment manifest. We call Mage as an Exec
task in the MSBuild project.
Upvotes: 0