首页 > 解决方案 > 在发布时配置 ClickOnce 包

问题描述

我正在处理从旧的手动实施的 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)。不幸的是,我不能重用上述可执行文件来重新签名。

我只有他们的证书指纹。但我不知道该怎么办。

问题:

  1. 我还有什么其他选择可以重新签署包裹?
  2. 有一个更好的方法吗?我是否必须为此解决方案进行另一个构建步骤?

标签: azure-devopsclickonceazure-pipelines-release-pipelinesigning

解决方案


我已经成功地使用dotnet mage签署了 ClickOnce Appmanifest( *.application) 和发布文件。我通过在安全文件中添加证书(或)文件并在管道变量中添加证书密码来完成此操作。*.exe.manifest.pfx.p12

在此处输入图像描述

  1. 使用 .NET Core 任务指定使用版本 5.x。
  2. 可选步骤通过重新安装dotnet tool update --global microsoft.dotnet.mage --version 5.0.0
  3. 在 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)"

推荐阅读