Sun, 01 Jan 2006

ClickOnce File Updating (Continued)

My initial observation about how doing a publish in Visual C# 2005 Express always rebuilds all assemblies was flawed: I had a pre-build script in that particular project that puts version numbers into the AssemblyInfo.cs file. Even if the version number did not change, the AssemblyInfo.cs file timestamp was updated, triggering a full rebuild of every project in my solution. My bad. It's a good reminder to always test a behaviour using the simplest possible setup.

The default behaviour of Visual C# 2005 Express (in the absence of any special pre-build scripts) is that, if you click on the "Publish Now" button twice in a row, without making any changes (direct or indirect) to any of the files, only the current project gets rebuilt; all the referenced projects are not rebuilt. This seems pretty reasonable.

Still, the current ClickOnce versioning is problematic. Try this:

  1. Publish the application.
  2. Execute the "Rebuild Solution" menu item in the "Build" menu.
  3. Publish the application. Notice that all assembly hashes have now changed.

So, if the solution gets rebuilt between publishes, then the second publish will do a total update, regardless of whether it is really needed.

This is not the behaviour that I want for my project. I often do a "rebuild all", for example before running FxCop or doing unit tests: I like to point both tools at my release binaries. I want ClickOnce to only update those assemblies whose version number has been bumped. I think that, if I control the publish manually, I should be able to get the desired behaviour.

posted at: 23:28 | path: / | permanent link to this entry