Testing ClickOnce Deployments

I had a question from a reader about testing ClickOnce deployments, andI thought I would pass my response along to anyone who is interested.

When you deploy a ClickOnce application, there are two manifests published with the application files to the deployment server: the deployment manifest (.application in Beta 1) and the application manifest (.exe.manifest in Beta 1). Bit of a confusing file extension choice if you ask me, but…

The deployment manifest includes information describing the deployment itself, including publisher information and a publish version that should be incremented each time you deploy a new set of files. The application manifest contains information that describes the application as a whole, including the collection of files that compose the application, and the permissions that the application requires.

When the application gets deployed to a client machine, a number of things are created at deployment. If the application publish settings are for it to only be available online, then the application files get cached under some obfuscated directories under the users profile \Documents and Settings\\Local Settings\Apps. Additionally, an Application Trust will be created as part of the User Code Access Security policy for that version of the app. Finally, if the application puslishing properties are set so that application is available offline as well as online, then a Start menu shortcut and an Add/Remove Programs item is added.

The question had to do with had to do with problems they were encountering in repeatedly deploying an app to a client machine for testing. The deploy and launch mechanisms for ClickOnce are designed around the concept that the publish version should be incremented to indicate to a client machine that there is a new version to download. Although it might seem that you could just go delete the files from under the user’s cache and redeploy to the same machine, you would also need to make sure all the other stuff mentioned above is also cleaned up.

There are two correct solutions to the problem of repeatedly deploying the same application to the same client machine for testing purposes.

1) Increment the publish version in the deployment manifest for each attempt. This can be done with the mage.exe tool found in the SDK bin folder. This will result in a new clean deployment to the machine each time.

2) Use a virtual machine (VMware is my preference, but VPC is fine too) in snapshot mode, where shutting down the virtual machine discards any changes made in the VM since you ran it. Now you can revert to the snapshot with a clean machine for each test.

If you test be manually deleting the files and artifacts from the user’s machine, you are not testing the way ClickOnce was designed to be and should be used. In other words, you are not testing well.