Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate from Visual Studio ClickOnce "Publish" wizard to MSBuild/mage deployment?

Tags:

clickonce

mage

Up until now our app has been published using ClickOnce via the Visual Studio "Publish" wizard. This has been rather painful, and we've automated the process using msbuild/mage.

Unfortunately, the new deployment does not appear to be compatible with the old one, giving the "The deployment identity does not match the subscription" error when the (test) users update.

Now there are plenty of differences between the files generated using "Publish" and our Mage script, but we can't eliminate them all. For example, "Publisher" doesn't seem to be respected by GenerateDeploymentManifest, while Mage -New Deployment can't set UpdateMode to Foreground. There are other similar cases.

Has anyone ever successfully moved away from the "Publish" wizard without requiring the entire user base to reinstall the app? What was your approach?

P.S. VisualStudio 2008; all users are on .NET Framework 3.5 SP1.

like image 722
Roman Starkov Avatar asked Jan 04 '10 23:01

Roman Starkov


People also ask

How do I publish a ClickOnce application using the Publish Wizard?

In Solution Explorer, right-click the application project and click Properties. The Project Designer appears. Click the Publish tab to open the Publish page in the Project Designer, and click the Publish Wizard button. The Publish Wizard appears.

What is publish with ClickOnce?

ClickOnce is a new application deployment technology that makes deploying a Windows Forms based application as easy as deploying a web application. ClickOnce applications can be deployed via web servers, file servers or CDs.

Which wizard to be used to publish applications desktops and assign users?

Use the Publish Wizard to copy solution files to a specified location, create the manifest files, and create a Setup program. To access this wizard, on the Build menu, choose Publish SolutionName. You can also access the Publish Wizard from Solution Explorer.


1 Answers

The trick was to match the so-called assembly identity.

Hint #1: do not use Mage to generate the deployment manifest (the *.application file). Use GenerateDeploymentManifest instead. The Mage tool lacks two crucial options:

  • Mage provides no way to specify the culture of the deployment. As you can see from the link above, if the culture doesn't match then to ClickOnce it's a different application. Ouch.
  • It's not possible to set the update mode to "foreground", aka "check updates before starting", aka "online application". Hmm...

Hint #2: DO use Mage to add publisher and sign the deployment certificate. This is because GenerateDeploymentManifest seems to ignore Publisher (in 3.5 SP1 at least), and similarly SignFile is unable to use a .pfx file as the key. Whoops.

<Exec Command='"c:\path\to\mage.exe" -Update "$(MyOutputPath)\MyApp.application" -Publisher MyCompany.com -CertFile path\to\MyAppKey.pfx'/>

Hint #3: to supply the correct relative path for the "codebase" field in the deployment XML, use the following snippet:

<CreateItem Include="$(MyDeploymentPath)\v$(Version)\MyApp.exe.manifest" AdditionalMetadata="TargetPath=v$(Version)\MyApp.exe.manifest">
  <Output TaskParameter="Include" ItemName="EntryPoint"/>
</CreateItem>

and then pass EntryPoint="@(EntryPoint)" to GenerateDeploymentManifest. The key bit is the "TargetPath" metadata. Yuck!

Hint #4: patience, a supply of old working manifests, and a good comfy diff tool.


Is this complicated and painful? Yes! But is it better than the Publish wizard? OH YES!

Edit: I've posted a working example of how one might invoke Mage from MSBuild - however working doesn't mean you can just plug it in, since there are lots of settings involved that you may want to change, and you still need to understand ClickOnce to some extent. But hopefully it can provide a useful starting point.

like image 170
Roman Starkov Avatar answered Sep 23 '22 18:09

Roman Starkov