ClickOnce on Multiple Environments
Friday, January 26, 2007 15:53If you have a ClickOnce application that is deployed in several environments, for example a staging environment and a production environment, you would have come across the fact that you can’t simply install the application on a client PC from both environments even though you try to install from different URL’s.
This can be overcome by using different certificates to sign the manifest files of each environment and by using a different name so that you’d get a different menu item for each environment. You’d have a “production.pfx” and a “staging.pfx” to sign the manifests of the production and staging environments respectively. By doing this now you can have side-by-side installations of the ClickOnce applications for each of your environments.
If you build your applications using visual studio itself, then changing the signing certificate file and name is one of the things you’d have to do before each build. But what if you’ve got a automated build environment, how do you do it then?
One way is to use the Manifest Generation and Editing (Mage.exe) command line tool to manually deploy the ClickOnce applications. If NAnt is what use Neil’s blog post on ClickOnce deployment using NAnt should get you started.
If you’re using CruiseControl.NET for your builds and you could do all this from the MsBuild task and pass in all the necessary changes for each environment as buildArgs. In this case we need to change the ManifestKeyFile and the ManifestCertificateThumbprint (This is the certificate thumbprint, in Visual Studio you can see this by clicking on the “more details” button on the “Signing” tab on the “Properties” page of your project)
Example of a CCNet MsBuild Task block where we change these values:
<!–Staging–>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<workingDirectory>C:\MyClickOnce\</workingDirectory>
<projectFile>MyClickOnce.csproj</projectFile>
<buildArgs>/p:Configuration=Release
/p:InstallUrl=https://www.staging.url/
/p:PublisherName=”Staging App”
/p:ManifestKeyFile=”Staging.pfx”
/p:ManifestCertificateThumbprint=”9DAAADE32307C99743FC74A475D6008370C65642″
</buildArgs>
<targets>Build;Publish</targets>
<timeout>15</timeout>
</msbuild>
Then you’d have another MsBuild task block to create the Production application.
I hope this helps someone, or points to some direction of a way of achieving a side-by-side ClickOnce installations of multiple environments.