DevOps 发布管道中不同阶段的复杂 web.config 转换

发布于 2025-01-09 00:32:09 字数 360 浏览 4 评论 0原文

我是 Azure DevOps 和设置 Azure DevOps CI-CD 管道的新手。我们的项目解决方案包含多个项目,包括旧版本的.Net Web 表单、MVC、API、.NetCore 项目。相应项目的 web.config 或 appsettings.js 非常复杂,包含许多自定义部分,需要根据目标环境进行修改。通常我们通过传递环境名称来转换配置文件并手动将其推送到相应的环境来构建我们的解决方案。

作为 CI-CD 的一部分,我们需要为所有环境实现整个 CD 的自动化。我们创建的构建管道遵循类似的方法来传递编译项目的环境名称,然后存储在工件位置。现在 CD 管道如何为每个阶段的预期环境生成或转换配置文件?注意:CI 处理后,只有转换后的 web.config 在关节位置可用。

I am new to Azure DevOps and setting up Azure DevOps CI-CD pipeline. Our project solution contains multiple projects including older version of .Net web forms, MVC, APIs, .NetCore projects. web.config or appsettings.js for corresponding project is very complex and contains many customs sections which needs to be modified depending on target environment. Usually we build our solution by passing the environment name to transform the configuration file and push it manually to corresponding environment.

As part of CI-CD we need to automate entire CD for all environments. Build pipeline that we created is following similar approach to pass environment name compiling the projects, then store in artifactory location. Now how can CD pipeline generate or transform config files for intended environment for each stage? Note: After CI process, only transformed web.config is available in articatory location.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姐不稀罕 2025-01-16 00:32:09

开发人员为此所做的努力是在 web.release.config 中添加转换,而不是硬编码值。 https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic

从 CI/CD 中,它应该根据令牌前缀和后缀动态替换发布管道中的值。其中一项任务 https://marketplace.visualstudio.com/items?itemName=qetza.replacetokens

要在 Visual Studio 中预览配置转换,请使用 https://marketplace.visualstudio.com/items?itemName=GolanAvraham.ConfigurationTransform

Developers effort for this would be adding transform in web.release.config rather than hard coding values. https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic

From CI/CD, it should be replacing values dynamically in the Release pipeline based on Token Prefix and Suffix. One such tasks https://marketplace.visualstudio.com/items?itemName=qetza.replacetokens

To preview config transforms in Visual Studio, Utilize https://marketplace.visualstudio.com/items?itemName=GolanAvraham.ConfigurationTransform

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文