基于 Stage 的 Azure Pipelines 配置转换 [英] Azure Pipelines Config Transform based on Stage

查看:38
本文介绍了基于 Stage 的 Azure Pipelines 配置转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的构建/发布管道中的配置文件遇到了问题.

阅读本页:

我希望发布管道对我的应用服务作业执行配置转换,但问题是发布时从未复制 Web.UAT.config.

在我自己的计算机上,如果我右键单击项目并选择发布,Web.UAT.config 文件也永远不会显示在输出中.

如何强制将此文件打包到我的部署包中,以便我可以为 UAT 阶段运行转换?

计划包括一个用于 UAT,一个用于 PRODUCTION,以便在发布版本时每个都获得正确的设置.

任何帮助将不胜感激.

干杯,

解决方案

我想出了如何强制将转换包含在发布中.

我通过使用 MSBuild 目标在此处找到了答案.

发布后,现在包含转换.

发布管道现在根据 Stage 名称运行转换,例如 Web.UAT.config 与我的名为 UAT 的阶段匹配释放管道.要让它运行配置转换,您只需在应用服务部署下的发布步骤中勾选 XML 转换 复选框.

I'm running into trouble with config files in my Build/Release pipelines.

Reading this page: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic#xml-transformation shows that you can have

*.<stage>.config (for example, fabrikam.Production.config)

I created a file called Web.UAT.config in my asp.net C# WebApplication. The properties on that file is set to Content, DoNotCopy, which should put it in the output directory on publish. I checked the existing web.config file and it's the same.

I want the release pipeline to perform the config transform on my App Service Job, but the problem is that the Web.UAT.config is never copied when publishing.

On my own computer if I right click on the project and select publish, the Web.UAT.config file is also never shown in the output.

How do I force this file to be packaged up in my deployment package so that I can run the transform for the UAT stage?

The plan is to include one for UAT, and one for PRODUCTION so that each one gets the correct settings when the release is pushed out.

Any help would be appreciated.

Cheers,

解决方案

I have figured out how to force the transforms to be included in the publish.

I found the answer here by using an MSBuild target.

After publishing, the transforms are now included.

The release pipeline now runs the transformation based on Stage name for example Web.UAT.config which matches a stage called UAT in my release pipeline. To get it to run the config transform you just need to tick the XML Transformation checkbox in your release step under App Service Deployment.

这篇关于基于 Stage 的 Azure Pipelines 配置转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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