VSTS JSON 变量替换为默认发布变量
VSTS JSON Variable Substitution with Default Release Variables
TL; DR
有什么方法可以在 VSTS 中使用 JSON variable substitution with default Release variables 吗?
描述
使用 VSTS,我可以在发布时使用 JSON 变量替换来设置 appsettings.json
文件中的值。例如,appsettings.json
文件如下所示:
{
"ConnectionStrings": {
"DM_ADJ": "placeholder",
"DM_SALES": "placeholder"
},
// And so on. Placeholders get replaced
}
我可以在 VSTS 中定义一个名为 ConnectionStrings.DM_ADJ
的 Release 变量,我在那里提供的值将替换相应 JSON 行中的 "placeholder"
。
现在,我还想在我的应用配置中使用一些默认的 Release 变量。例如,默认的 Release 变量称为 Release.DefinitionName
和 Release.DefinitionId
。我认为我可以将它们替换为如下所示的 appsettings.json
配置部分,但不幸的是,当发布完成时,"placeholder"
字符串不会被替换。我错过了什么吗?
{
"Release": {
"DefinitionName": "placeholder",
"DefinitionId": "placeholder",
}
// And so on. Placeholders do not get replaced
}
这是预期的行为,因为它排除了 build/release 的系统定义变量:
如果要使用 json 文件中的系统定义变量,创建一个自定义变量并将值设置为系统定义变量,如下所示,而不是直接使用系统定义变量:
您需要指定要更改值的 json 文件
那么您只需要创建一个变量,其中包含您要更改的路径。
例如我想更改 属性 版本
所以,我需要用这个名称创建一个变量:
Aplicacao.Version
TL; DR
有什么方法可以在 VSTS 中使用 JSON variable substitution with default Release variables 吗?
描述
使用 VSTS,我可以在发布时使用 JSON 变量替换来设置 appsettings.json
文件中的值。例如,appsettings.json
文件如下所示:
{
"ConnectionStrings": {
"DM_ADJ": "placeholder",
"DM_SALES": "placeholder"
},
// And so on. Placeholders get replaced
}
我可以在 VSTS 中定义一个名为 ConnectionStrings.DM_ADJ
的 Release 变量,我在那里提供的值将替换相应 JSON 行中的 "placeholder"
。
现在,我还想在我的应用配置中使用一些默认的 Release 变量。例如,默认的 Release 变量称为 Release.DefinitionName
和 Release.DefinitionId
。我认为我可以将它们替换为如下所示的 appsettings.json
配置部分,但不幸的是,当发布完成时,"placeholder"
字符串不会被替换。我错过了什么吗?
{
"Release": {
"DefinitionName": "placeholder",
"DefinitionId": "placeholder",
}
// And so on. Placeholders do not get replaced
}
这是预期的行为,因为它排除了 build/release 的系统定义变量:
如果要使用 json 文件中的系统定义变量,创建一个自定义变量并将值设置为系统定义变量,如下所示,而不是直接使用系统定义变量:
您需要指定要更改值的 json 文件
那么您只需要创建一个变量,其中包含您要更改的路径。 例如我想更改 属性 版本
所以,我需要用这个名称创建一个变量:
Aplicacao.Version