问题描述
我正在处理从旧的手动实施的 ci/cd 解决方案到 Azure DevOps 的管道迁移。 我仍在重用一些预构建的函数/流程。
例如。就像他们如何将所有解决方案打包为工件一样。
我正在尽量减少代码更改。
构建管道创建 ClickOnce 包 .zip
。
然后在发布阶段,应用程序文件中的 myapp.exe.config
通过 XML-Document-Transform 进行转换。此外,应用程序清单 <ApplicationName>.application
也是通过 Powershell 手动编辑的。根据要部署到的环境/路径,<deploymentProvider codebase="http://1.1.1.1/samplefolder/myapp.application" />
在发布时会发生变化。
应用程序清单
<asmv1:assembly ...>
<deployment ...>
<subscription>
<update>
<beforeApplicationStartup />
</update>
</subscription>
<deploymentProvider codebase="http://1.1.1.1/samplefolder/myapp.application" />
</deployment>
</asmv1:assembly>
现在我明白这个方法需要对整个包进行重新签名。他们有一个自定义的 .exe
文件来重新签署整个包(它不是 mage.exe)。不幸的是,我无法重用上述可执行文件来重新签名。
我只有他们的证书指纹。但我不知道该怎么办。
问题:
解决方法
我已成功使用 dotnet mage 在发布时签署了 ClickOnce Appmanifest (*.application
) 和 *.exe.manifest
文件。我通过在安全文件中添加证书(.pfx
或 .p12
)文件并在管道变量中添加证书密码来完成此操作。
- 使用 .NET Core 任务指定使用版本 5.x。
-
可选步骤通过
dotnet tool update --global microsoft.dotnet.mage --version 5.0.0
重新安装
- 在 powershell 中运行以下代码
## Signing the exe.manifest file
dotnet mage -update "<folder>/Application Files/<assembly folder name>/<assemblyname>.exe.manifest" -fd "<folder>/Application Files/<folder>" -CertFile "$(SignKey.secureFilePath)" -Password "$(SignKeyPassword)"
## Signing the .Application file
dotnet mage -update "<the .Application full path>" -pu "$publisherURL" -pub "$(PublisherDetails)" -appmanifest "Application Files/<assembly folder name>/<assemblyname>.exe.manifest" -CertFile "$(SignKey.secureFilePath)" -Password "$(SignKeyPassword)"