如何使用 mage.exe 为 VSTO 重新分配清单?

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

我们有一个 Excel 插件作为我们 Visual Studio 解决方案的一部分。该插件构建一次,然后作为我们 CI/CD 流程的一部分部署到不同的环境(dev、uat、prod)。

在部署期间,我们应用应用程序配置转换以使用正确的环境配置更新 Excel 插件配置。

因此,清单和 VSTO 需要辞职。我浏览了很多 SO 帖子(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 等)和 MSDN 帖子,但无法找到调用 mage.exe 的正确方法。

我尝试了 mage.exe -update ...mage.exe -sign ... 和其他一些组合,当我尝试启动 VSTO 时,它们都会导致代理或无效清单,例如

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

有没有人知道重新签署 VSTO 时要与 mage.exe 一起使用的正确签署顺序和标志?

在更新 VSTO 文件之前,您需要先更新应用程序清单。

mage -update yourFile.dll.manifest -CertFile certificate.pfx -Password密码

然后您需要使用您已经更新的应用程序清单来更新 VSTO。

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

上述正确答案的附加信息是,如果使用证书存储或 USB 令牌,则您需要提供 -CertHash“证书指纹”而不是 -CertFile“证书文件路径”

mage -update yourFile.dll.manifest -CertHash“cert-thumb-print”