Automate publish of ClickOnce using Visual Studio 2008

clickoncemsbuildpublish

I have a Visual Studio solution file (.sln), with several projects (VB.NET and C#, .vbproj, and .csproj files, respectively), and I have a Windows application, and I use ClickOnce to publish it.

Now, I need automate the Publish option using MSBuild or another good solution (cmd, VBScript, or BAT scripts).

How can I do it?

Best Answer

Well, ClickOnce uses MSBuild to publish itself. Therefore I would recomment to use MSBuild for your build-automation. See the reference on MSDN.

The first step is easy. You just run MSBUild with 'Publish'-target from the console. The settings made in Visual Studio are applied.

However, there are some tricky bits. For example, when you run it from the command line, the version number isn't increased. In my project I've solved this by passing the version-number from the build script.

Another tricky-part is when you want to run the build script on your build-server without Visual Studio installed. There you might have to copy some to make it work.