如何在不同环境中使用 Azure DevOps Pipeline 发布 ClickOnce 应用程序? [英] How to Publish a ClickOnce application with Azure DevOps Pipeline on different environments?

查看:21
本文介绍了如何在不同环境中使用 Azure DevOps Pipeline 发布 ClickOnce 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

这是我的构建定义

这是我的构建参数

/target:publish/p:ApplicationVersion=$(Build.BuildNumber)/p:PublishURL=http://app-staging.example.com//p:UpdateEnabled=true/p:UpdateMode=前景/p:ProductName="应用暂存"/p:OutputPath="$(build.ArtifactStagingDirectory)Publish\"

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

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

解决方案

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

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

步骤:- 任务:FileTransform@1displayName: '文件转换:'输入:文件夹路径:App.ExampleenableXmlTransform: 真xmlTransformationRules: '-transform ***.Staging.config -xml ***.config'文件类型:xml

#您的构建管道引用了BuildPlatform"变量,您已选择在排队时对其进行设置.创建或编辑此 YAML 文件的构建管道,在变量"选项卡上定义变量,然后选择在排队时使其可设置的选项.请参阅 https://go.microsoft.com/fwlink/?linkid=865971脚步:- 任务:VSBuild@1displayName: '构建解决方案'输入:解决方案:example.slnmsbuildArgs: '/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\"'平台:'$(构建平台)'配置:暂存

I try for several days now to publish my ClickOnce application with Azure DevOps Pipeline. Before going in detail here is what I would like to do from my release view:

I started with one artifact and 2 release stage modifying the config.deploy file with staging variables during my Staging stage and modifying the config.deploy file with production variables during my Production stage. Deployment was working fine but installation of application was not working because of hash check system.

So I decided to create 2 builds with 2 artifacts. I renamed the classic drop by a drop_staging during my first build and drop_production for my second build. I was hoping the build system (MSBuild) was able to select the correct app.Debug.config then app.Release.config file during the build and publish process.

Here is my build definition

Here is my build arguments

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

Configuration is set to Staging for first build then on Production for second build. I have, of course, a Staging and Production build definition in visual Studio. I have an app.config with app.Staging.config and app.Production.config in my project.

I cannot simply add a task to transform my config file after the build because I will not respect the hash. I should find a way to say to my build to use the correct XML transformation config file. I don't see any other solution or maybe applying this transformation before the build? Is it possible? What are your solutions?

解决方案

finally I could solve this by adding a file transform before my build.

In case you need more help here is my YAML detail for transformation

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

这篇关于如何在不同环境中使用 Azure DevOps Pipeline 发布 ClickOnce 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆