Automating Publish of ClickOnce with TeamCity
Build multiple ClickOnce deployment packages using MSBuild and Team City
Building ClickOnce with TeamCity
ClickOnce certificate and TeamCity
Build ClickOnce deployment packages using MSBuild and Team City
Yesterday I was asked to solve one minor issue. At ClickOnce publishing time the publish.htm file was not generated so the ClickOnce version number on the web page wasn’t shown. The publish.htm file is a static file on the targeted deploy directory and IIS uses that file. The file contains a hard coded version 2.0.0.x.
So from a user perspective it was difficult to know if there were a new version. So I was asked to show the correct version.
I knew from past research a way to handle this from the following post: How To: Generate publish.htm with MSBuild
But I went to a more pragmatic solution, as I already had the MSBuild Community Tasks.
I made a copy of Publish.htm to Publish.htm.ori on each targeted deploy directory.
Then I modified my MSBuild script to do the following:
- Copy Publish.html.ori to Publish.htm
Use FileUpdate of MSBuild Community Tasks to search the 2.0.0.x string and replace it with the version
- <Target Name=“DeployClickOnce“>
- <Message Text=“####### Deploy ClickOnce $(Configuration)|$(Platform) ———#“ />
- <Exec Command=“xcopy /E /Y $(ClickOnceSrc)*.* $(ClickOnceDestination)“ />
- <Copy SourceFiles=“$(ClickOnceDestination)\Publish.htm.ori“ DestinationFiles=“$(ClickOnceDestination)\Publish.htm“ />
- ReplacementText=“$(FullVersion)“ />
and the FullVersion is defined as this, using TeamCity BUILD_VCS_NUMBER, which is Latest VCS revision:
- <FullVersion>$(Major).$(Minor).$(Build).$(Revision)</FullVersion> </PropertyGroup>
And now the Publish webpage display the version correctly!