Wednesday, February 10, 2010

Publish click once application via MSBuild

By default, the only way to create a click once installed application is to publish via Visual Studio. If you are planning to automate your builds using TFS Team Build projects, you will need the following task to actually publish your product:

In your TFSbuild.proj, use the following MSBuild task:
<MSBuild Projects="$(SolutionRoot)\MyProduct.UIShell\MyProduct.UIShell.csproj"
Properties="Configuration=%(ConfigurationToBuild.FlavorToBuild);
PublishUrl=http://appserver/MyProduct/;
PublishDir=$(OutDir)_PublishedWebsites\MyProduct.UI\;
InstallUrl=http://appserver/MyProduct/;
InstallFrom=Web;
DTPublishDir=$(OutDir)_PublishedWebsites\MyProduct.UI\;
ApplicationVersion=$(ClickOnceVersion);
ProductName=MyProduct_DEV; <--NOTE: this allows you to publish different versions of the same product.
PublisherName=MyCompany;"
Targets="Publish" />


Additionally, checking the "minimum version required" option under the Update panel will cause clients to be updated without the option to skip new versions (assuming the client already had a prior version installed). The clients will also be required to get a version that is higher than what is marked as minimum.