首页 > 解决方案 > 替换令牌任务不适用于我的 .json 文件

问题描述

下面是我的 .net 核心项目的 appsettings.json 文件的内容。我在我的发布管道中使用替换令牌任务。我正在尝试替换 appsettings.json 文件中的变量 IrtMfdDb 的值,并将输出保存为appsettings2.json。所以我创建了一个变量组,其中包含一个名为ConnectionStrings.IrtMfdDb的变量,使用 json 路径并保持大小写相同。

当我运行该版本时,它似乎确实找到了我的 appsettings.json 文件,但是它不会替换令牌ConnectionStrings.IrtMfdDb。查看说明,它仅声明使用 json 路径作为变量名声明变量,并且设置的任何值都将被替换为新值。这不起作用,所以我显然遗漏了一些东西。有人可以解释我可能做错了什么吗?

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "ConnectionStrings": {
    "GlobalMaster": "Data Source=MySQL001;Initial Catalog=GLOBALMASTER;Integrated Security=True;Application Name=My.API.Infrastructure",
    "MasterDb": "Server=MySQL001;Initial Catalog=GlobalMaster;Trusted_Connection=True;",
    "IrtMfdDb": "Server=MySQL001;Initial Catalog=MyCatalog;Trusted_Connection=True;"
  }
}

我的变量组

标签: json.net-core

解决方案


推荐阅读