Search code examples
c#clickoncemage

How to use mage.exe to resign manifests for VSTO?


We have an Excel plugin as part of our Visual Studio solution. The plugin is built once and then deployed out to different environments (dev, uat, prod) as part of our CI/CD process.

During the deploys we apply an app config transform to update the Excel plugin config with the correct environmental config.

As such, the manifest and VSTO needs resigning. I've been through a number of SO posts (Use mage.exe to create a ClickOnce deployment manifest for *.deploy files, Resign manifest of click-once application change from 4.0 to 4.5, Resign Clickonce manifest using mage.exe etc.) and MSDN posts and cannot work out the correct way to call mage.exe for this to work.

I've tried mage.exe -update ..., mage.exe -sign ... and a couple of other combinations that all result in broker or invalid manifests when I try to launch the VSTO e.g.

C:\Tools\mage.exe -update "$CodeBasePath\MyCompany.vsto" -certFile "$CertFile" -password "$CertPassword" -appManifest "$AppManifestPath"

Does anything know the correct order of signing and flags to use with mage.exe when re-signing a VSTO?


Solution

  • before updating the VSTO file you need to first update the application manifest.

    mage -update yourFile.dll.manifest -CertFile certificate.pfx -Password password

    Then you need to update the VSTO with the application manifest you already updated.

    mage -update yourFile.vsto -appmanifest yourFile.dll.manifest -CertFile certificate.pfx -Password password