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

问题描述 投票:0回答:1

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

enter image description here

我从一个工件和两个发布阶段开始,在我的暂存阶段中用阶段变量修改config.deploy文件,在生产阶段中用生产变量来修改config.deploy文件。部署工作正常,但由于使用了哈希检查系统,因此无法安装应用程序。

因此,我决定用2个工件创建2个构建。我在第一个构建中通过_drop_staging重命名了经典的drop,在第二个构建中将其重命名为drop_production。我希望构建系统(MSBuild)在构建和发布过程中能够选择正确的app.Debug.config然后是app.Release.config文件。

这是我的构建定义

Build definition

这是我的构建参数

/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\\"

配置在第一个构建中设置为暂存,然后在生产中构建第二个构建。我在Visual Studio中当然有一个暂存和生产版本定义。我的项目中有一个app.config,其中包含app.Staging.config和app.Production.config。

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

azure-devops clickonce azure-pipelines
1个回答
0
投票

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

enter image description here

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

steps:

- task: FileTransform@1

  displayName: 'File Transform: '

  inputs:

    folderPath: App.Example

    enableXmlTransform: true

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

    fileType: xml

#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
© www.soinside.com 2019 - 2024. All rights reserved.