在发布时配置 ClickOnce 包

Hex*_*xed 5 clickonce signing azure-devops azure-pipelines-release-pipeline

我正在致力于从旧的手动实现的 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>
Run Code Online (Sandbox Code Playgroud)

现在我明白这种方法需要对整个包进行重新签名。他们有一个自定义.exe 文件来重新签名整个包(不是mage.exe)。不幸的是,我无法重复使用上述可执行文件来重新签名。

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

问题:

  1. 重新签署包裹还有哪些其他选择?
  2. 有一个更好的方法吗?我是否需要为此解决方案执行另一个构建步骤?

Hex*_*xed 2

我已成功使用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)"
Run Code Online (Sandbox Code Playgroud)