13 March 2009

Deploying .NET Applications - Learning MSBuild and ClickOnce

by mo

I recently finished reading.

Deploying .NET Applications: Learning MSBuild and ClickOnce (Expert's Voice in .Net)

I was interested in this book mainly to find an easier way to deploy ClickOnce applications via an automated build. Most of my build automation experience has been with Nant, so I figured learning MSBuild couldn't hurt.

This book targets the Visual Studio 2005 time frame, so some of the things that it describes is out dated, mainly in regards to ClickCnce.

There was a little coverage on mage.exe but not as much as I had liked. If you're looking for a book to get you into the world of Clickonce or MSBuild, this one's pretty good!

Here are some of the things that I learned straight from the book.


Microsoft.Build.Framework and Microsoft.Build.Utilities contains some stuff to help you with your builds. There's an ITask interface and a Task base class that you can implement if you want to run some custom tasks from MSBuild.

ClickOnce is driven by two XML-based manifest files called the deployment manifest and the application manifest.

  • Deployment manifest (.application) contains information specific to the deployment of the system.
  • Application manifest (.manifest) captures information specific to version of the system.

ClickOnce Deployment

The ClickOnce technology also has a programmatic interface that you can use to customize deployment and updates. For example, if you have a plug-in where the core of the application is deployed initially and then users are allowed to choose optional features (plug-ins) and have them installed on demand, the ClickOnce API can help.

ClickOnce applications have to be deployed to a Web server, to a file server, and/or to removable media (such as CD/DVD). Moreover, you can deploy these applications in one of two modes: offline or online.

For applications that require finer-grained control over doing updates, application authors can use the ClickOnce APIs to customize installation and updates.

Code Access Security (CAS)

  • Permission: The authority to do something.
  • Permission set: A grouping of arbitrary permissions.
  • Origin based Evidence: Where your code comes from determines what permissions your code gets.
  • Content base evidence: Your code content is signed and has a publisher certificate, and that determines what permissions you get.
  • Code Group: Associates evidence with a permission set
  • Security Policy: Policies define a hierarchy of code groups.

On-Demand Download

ClickOnce offers a facility that called on-demand download. The idea is that you create groups of files and then use the ClickOnce APIs to download each group at runtime. The initial download is reduced to what is needs to be downloaded to run the application, and if a piece of functionality is not needed, it is not downloaded.

You can get the path to the Data directory via:

  • AppDomain.CurrentDomain.GetData("DataDirectory");
  • ApplicationDeployment.CurrentDeployment.DataDirectory;
  • Application.LocalUserAppDataPath;
books csharp