如何在不同环境中使用 Azure DevOps Pipeline 发布 ClickOnce 应用程序?

Bas*_*mme 7 clickonce azure-devops azure-pipelines

我尝试了几天来使用 Azure DevOps Pipeline 发布我的 ClickOnce 应用程序。在详细介绍之前,我想从我的发布视图中执行以下操作:

在此处输入图片说明

我从一个工件和 2 个发布阶段开始,config.deploy在我的 Staging 阶段使用 staging 变量修改config.deploy文件,并在我的 Production 阶段使用生产变量修改文件。部署工作正常,但由于哈希检查系统,应用程序的安装无法正常工作。

所以我决定用 2 个工件创建 2 个版本。我drop_staging在第一次构建和drop_production第二次构建期间将经典 drop 重命名为 a 。我希望构建系统 (MSBuild) 能够在构建和发布过程中选择正确的app.Debug.configthenapp.Release.config文件。

这是我的构建定义

构建定义

这是我的构建参数

/target:publish 
/p:ApplicationVersion=$(Build.BuildNumber) 
/p:PublishURL=http://app-staging.example.com/   
/p:UpdateEnabled=true  
/p:UpdateMode=Foreground  
/p:ProductName="App Staging" 
/p:OutputPath="$(build.ArtifactStagingDirectory)\Publish\\"
Run Code Online (Sandbox Code Playgroud)

配置设置为第一次构建的暂存,然后第二次构建的生产。当然,我在 Visual Studio 中有一个StagingProduction构建定义。我有一个app.configwithapp.Staging.configapp.Production.configin 我的项目。

我不能简单地添加一个任务来在构建后转换我的配置文件,因为我不会尊重哈希。我应该找到一种方法来告诉我的构建使用正确的 XML 转换配置文件。我没有看到任何其他解决方案,或者可能在构建之前应用此转换?是否可以?你的解决方案是什么?

Bas*_*mme 9

最后我可以通过在构建之前添加文件转换来解决这个问题。

在此处输入图片说明

如果您需要更多帮助,这里是我用于转换的 YAML 详细信息

steps:

- task: FileTransform@1

  displayName: 'File Transform: '

  inputs:

    folderPath: App.Example

    enableXmlTransform: true

    xmlTransformationRules: '-transform **\*.Staging.config -xml **\*.config'

    fileType: xml

Run Code Online (Sandbox Code Playgroud)
#Your build pipeline references the ‘BuildPlatform’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971



steps:

- task: VSBuild@1

  displayName: 'Build solution'

  inputs:

    solution: Example.sln

    msbuildArgs: '/target:publish /p:ApplicationVersion=$(Build.BuildNumber) /p:PublishURL=http://staging.example.com/   /p:UpdateEnabled=true  /p:UpdateMode=Foreground  /p:ProductName="App Staging" /p:OutputPath="$(build.ArtifactStagingDirectory)\Publish\\"'

    platform: '$(BuildPlatform)'

    configuration: Staging
Run Code Online (Sandbox Code Playgroud)

  • 伟大的!感谢您在这里分享您的解决方案,您可以接受它作为答案,这样它可以帮助遇到相同问题的其他社区成员,我们可以存档此线程,谢谢。 (3认同)