Eric's Blog

Day to day experience in .NET
Welcome to Blogs @ IRM Sign in | Join | Help
 Search

Disclaimer

The content of this site is my own personal opinion and does not in any way represent my employer, it's subsideries or affiliates. These postings are provided "AS IS" with no warranties, and confer no rights.

This Blog

Deploying ClickOnce to Multiple Environments

So in my struggling to get a lean and effective way to roll out new versions of an application for two of my clients, I have some more to share with you. I want it to be extremely easy for me to create a new ClickOnce installer for my clients and I have identified three things that I need to solve:

  • The installations will be run from different installation URL:s.
  • Getting unique config-files packed with the ClickOnce publish. I have 2 clients, each with a test and a production environment, and I need to handle my own test environment too.
  • A client machine needs to be able to run installations for both test and production on a single machine. This means that ClickOnce must see my applications as different applications even though it is only one.

I have solved the last two, so lets start with the last one.

Running both test and production environments on the same client

There are more than one way to solve this, but for me the easiest solution was to create two Visual Studio projects. Originally I had a single Windows Forms exe project in Visual Studio, but I changed this to be just a DLL-project (Output type in Application settings). Then I created two new projects with the names Application and Application.Test and for both of them I configured ClickOnce as usual. There is only a single line of code in each of these projects and that’s to call the original entry point in my old exe-project:

Program.Main(args);

With this solved I still needed to handle the differences in configurations.

Different config for each environment

Visual Studio 2010 has support for transforming configuration files when deploying a web project, but only when deploying and that is only supported for web projects. Luckily Sayed Ibrahim Hashimi and Chuck England have created a small VSiX called SlowCheetah XML Transforms that do the same thing, but when you build your project. So naturally the first step is to install the add-in. Next up is to create new project configurations in configuration manager (I created CustomerATest, CustomerAProd, CustomerBTest and CustomerBTest). With this in place you can right-click on the config-file in you project and select Add Transform, which adds a sub-config file for each configuration. In these config files you then apply the transformations for the changes you want to do in the config file.

This is so useful in many more scenarios than just for deploying with ClickOnce.


Unfortunately I haven’t solved the problem of having different installation URL:s for each configuration, but maybe someone has a tip? I have tried to edit the project file and move the installation url element to respective configuration. This works if I remember to reload the project each time I select another configuration (which I of course don’t), but if I don’t reload the settings will be overwritten with the value from the configuration that was used when the project was loaded so that won’t work. The best thing would of course be if Visual Studio could start to support different installation URL for each configuration.

Published den 14 september 2011 15:05 by ericqu

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Dew Drop – September 15, 2011 | Alvin Ashcraft's Morning Dew said:

september 15, 2011 14:46
 

RobinDotNet said:

This article may help you with the issue of deploying different app.config files for different environments. It was written by Saurabh Bhatia, the ClickOnce guy at Microsoft: http://blogs.msdn.com/b/vsto/archive/2010/03/09/tricks-with-app-config-and-clickonce-deployment-saurabh-bhatia.aspx And this one (by the same guy) will show you how to re-sign the manifests using mage. (This is about VSTO apps, but it works the same way for other apps). http://blogs.msdn.com/b/vsto/archive/2009/04/29/signing-and-re-signing-manifests-in-clickonce.aspx You can change the installation url when you re-sign the manifests, which should solve that problem for you.
september 19, 2011 07:11

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems