Thursday, October 18, 2007

Publishing a ClickOnce app with TeamBuild

From:http://geekswithblogs.net/thibbard/archive/2007/06/01/Publishing-a-ClickOnce-app-with-TeamBuild.aspx

After much frustration, I've finally configured our TeamBuild proj file to publish our ClickOnce app, and increase the version number (kinda an important step). The Vertigo blog talks about using SolutionToPublish, but that doesn't work for all situations. Specifically, when your solution contains projects that reference other projects.
So I started playing with the MSBuild Community Tasks Project, and came up with the following Xml for my proj file:
This tells the .proj to use the community project:
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\
MSBuild.Community.Tasks.Targets"/>
This defines the version numbers:
<propertygroup>
<major>4</major>
<minor>0</minor>
<build>0</build>
<revision>0</revision>
</propertygroup>

This sets the Revision to the last Changeset in our TFS server, and sets the Build to a formatted date:
<target name="Version">
<tfsversion localpath="$(SolutionRoot)">
<output taskparameter="Changeset" propertyname="Revision">
</tfsversion>
<time format="MMdd">
<output taskparameter="FormattedTime" propertyname="Build">
</time>
</target>

This tells TeamBuild to Publish this after the solution is compiled and after the Version code has been ran. It publishes the ClickOnce project to the location PublishDir with the version set in ApplicationVersion:
<target name="AfterCompile" dependsontargets="Version">
<MSBuild Projects="$(SolutionRoot)\dev\...\ParaPlan.csproj"
Properties="PublishDir=\\server\drop\;ApplicationVersion=$(Major).$(Minor).$(Build).$(Revision)"
Targets="Publish" />
</target>

The entire .proj file is here.

No comments: