Azure Devops发布管道XML变量替代不起作用 [英] Azure Devops Release Pipeline XML Variable Substitution not working

查看:92
本文介绍了Azure Devops发布管道XML变量替代不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的发布管道中有一个非常简单的变量替换,但是它不起作用.我在connectionStrings.config文件中有这样的变量:

I have a very simple variable substitution in my release pipeline, but it's not working. I have the variable in the connectionStrings.config file as such:

<?xml version="1.0"?>
<connectionStrings>
  <add name="ExpenseDBConnectionString" connectionString="__ProdConnString__" providerName="System.Data.SqlClient" />
</connectionStrings>

然后在发布管道中定义了变量:

I then have the variable defined in the release pipeline:

在部署任务中,我还启用了XML Variable Substitution:

I also have the XML Variable Substitution enabled in the Deploy Task:

但是我运行发行版,并且变量没有被替换.我在日志中收到此消息:

But I run the release, and the variable doesn't get substituted. I get this message in the logs:

2020-02-28T19:57:26.1262198Z Initiated variable substitution in config file : D:\a\_temp\temp_web_package_875508750741006\Content\D_C\a\1\s\Expenses.Web\obj\Release\Package\PackageTmp\App_Config\ConnectionStrings.config
2020-02-28T19:57:26.1312311Z Processing substitution for xml node : connectionStrings
2020-02-28T19:57:26.1321602Z Skipped Updating file: D:\a\_temp\temp_web_package_875508750741006\Content\D_C\a\1\s\Expenses.Web\obj\Release\Package\PackageTmp\App_Config\ConnectionStrings.config

这应该很简单,所以不确定我缺少什么设置.救命!

This should be pretty simple, so not sure what setting I am missing. Help!

推荐答案

您应在发布管道中将变量名称定义为ExpenseDBConnectionString.以下是设置XML variable substitution的说明.变量与keyname条目匹配

You should define your variable name as ExpenseDBConnectionString in the release pipeline. Below is the description of the setting XML variable substitution. The variables are matched against the key or name entries

在构建或发布管道中定义的变量将与任何配置文件和parameters.xml的appSettings,applicationSettings和connectionStrings部分中的"key"或"name"条目匹配.变量替换在配置转换后运行.

Variables defined in the build or release pipeline will be matched against the 'key' or 'name' entries in the appSettings, applicationSettings, and connectionStrings sections of any config file and parameters.xml. Variable Substitution is run after config transforms.

因此定义的变量应如下所示:

So the variable defined should be like below:

下面的屏幕快照是我的测试版本的结果,您可以看到connectionString被替换了.

Below screenshot is the result from my test release, you can see the connectionString was replaced.

有关XML变量替换的更多信息,请查看

For more information about XML variable substitution, please check it out here.

也有一些第三方替代工具(例如魔术块),可用于替换您的配置设置.请查看此线程的示例.

There are also some third party substitution tools(ie. Magic Chunks) that you can use to replace your config settings. Please check out the example for this thread.

这篇关于Azure Devops发布管道XML变量替代不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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