Azure Devops中针对不同环境的app.config转换 [英] app.config transformations in Azure Devops for different environments

查看:118
本文介绍了Azure Devops中针对不同环境的app.config转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.Net Framework 4.6.1项目,该项目创建一个Windows服务.我们希望通过Azure Devops管道来构建和部署它.我们已经成功地为所有.Net Core Web服务创建了管道(使用ASPNETCORE_ENVIRONMENT变量和一组appsettings.{ENV} .json文件),但是Windows Services在提供不同的服务方面似乎不能很好地发挥作用针对不同环境的配置.

I've got a .Net Framework 4.6.1 project, which creates a Windows Service. We want to have this built and deployed by an Azure Devops pipeline. We've successfully created pipelines for all of our .Net Core web services (using the ASPNETCORE_ENVIRONMENT variable and a set of appsettings.{ENV}.json files) but the Windows Services don't seem to play as nicely in terms of providing different configuration for different environments.

我已经为App.config XML文件进行了XDT转换.我可以右键单击Visual Studio和预览转换"中的文件,它可以正常工作.

I've got XDT transformations working for the App.config XML file. I can right click the files in Visual Studio and "Preview Transform" and it works fine.

目前尚不清楚我如何将其转换为管道配置. Build任务似乎能够运行转换,但是我不确定对于不同的Deploy阶段我们如何进行不同的转换.取而代之的是,所有环境最终都会对在构建"步骤中选择的构建配置"进行任何转换.

What's not clear is how I translate this to the pipeline configuration. The Build task seems to be capable of running the transform but then I'm not sure how we have a different transformation for different Deploy stages. What happens instead is that all environments end up with whatever transformation was applied to the Build Configuration selected as part of the Build step.

我关注了许多博客文章-包括

I've followed numerous blog posts - including this one, which claims you can have multiple build configurations, but for which I don't seem to have the setting.

我想念什么?

推荐答案

我们假设在较新的Azure Devops中,我们对VSTS所做的工作与之类似.我们将转换添加令牌到配置文件IE"DefaultConnection"中:"Server = DBServer ;数据库= DB;用户ID = DBUser ;密码= DBPassword ;"然后,在发布环境中有一个名为Tokenization的任务,该任务从发布环境中提取设置的变量以替换下划线的令牌.

What we do with VSTS which I assume is similar in the newer Azure Devops. We have the transformation add tokens to the config file IE "DefaultConnection": "Server=DBServer;Database=DB;User ID=DBUser;Password=DBPassword;" Then There is a task on the release enviroment called Tokenization which pulls variables set from the release enviorment to replace the underscored tokens.

我们使用此插件来执行标记化步骤. https://marketplace.visualstudio.com/items?itemName=TotalALM.totalalm-标记化

We use this plugin to do the tokenization step. https://marketplace.visualstudio.com/items?itemName=TotalALM.totalalm-tokenization

这篇关于Azure Devops中针对不同环境的app.config转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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