如何在不同的环境中使用Azure DevOps Pipeline发布ClickOnce应用程序? [英] How to Publish a ClickOnce application with Azure DevOps Pipeline on different environments?
问题描述
我现在尝试了几天,以使用Azure DevOps Pipeline发布ClickOnce应用程序.在进行详细介绍之前,我想从发布视图中进行以下操作:
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:
我从一个工件和两个发布阶段开始,在我的登台阶段用阶段变量修改config.deploy
文件,在生产阶段用生产变量修改config.deploy
文件.部署工作正常,但由于使用了哈希检查系统,因此无法安装应用程序.
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.
因此,我决定用2个工件创建2个构建.在第一次构建时,我用drop_staging
重命名了经典的drop,在第二次构建中,将drop_production
重命名了.我希望构建系统(MSBuild)在构建和发布过程中能够选择正确的app.Debug.config
然后是app.Release.config
文件.
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.
这是我的构建定义
这是我的构建参数
/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\\"
对于第一个版本,配置设置为 Staging ,对于第二个版本,则在生产上设置.当然,我在Visual Studio中有一个 Staging 和 Production 构建定义.我的项目中有一个app.config
和app.Staging.config
和app.Production.config
.
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.
在构建之后,我不能简单地添加一个任务来转换我的配置文件,因为我不会尊重哈希.我应该找到一种方法对我的构建使用正确的XML转换配置文件.我没有看到任何其他解决方案,或者可能在构建之前应用了此转换?是否有可能?您有什么解决方案?
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.
如果您需要更多帮助,这是我的YAML转换详细信息
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屋!