首页 > 解决方案 > 如何使用 web.config 转换在 APP 设置部分插入新密钥

问题描述

我想在应用设置部分插入新的键值,其他键值应该保持不变。

以下是我的源配置<

add key="UserName" value="Apple" /> 
    <add key="Main.ConnectionString" value="Data Source=testingdevmachine;Persist Security Info=false;User ID=test;Password=test;Validate Connection=true;" />
        <add key="CTCredentials01" value="userid@test|password@test&12|server@https://test/" />
        <add key="WFCredentials01" value="userid@test|password@Mango| server@https://test/ />

`

我的转换配置文件如下所示:

         <add key="CTCredentials01" value="userid@test123|password@test&12|server@https://test/" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
    <add key="WFCredentials01" value="userid@test123|password@Mango| server@https://test/" 
  xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/> 
    <add key="WFCredentials03" value="userid@test123|password@Mango| server@https://test/" 
  xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/> 
<add key="UserName" value="Nick"
        xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>

现在,从上面的 transform config add key="WFCredentials03" 我的源配置文件中没有这个键,那么我如何在我的转换配置文件中添加这里?

标签: asp.netazure-devopsweb-configweb.config-transformxdt-transform

解决方案


我建议你关注这篇文章,但从我上面看到的

<add key="WFCredentials03" value="userid@test123|password@Mango| server@https://test/" 
  xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/> 

你应该xdt:Transform="SetAttributes"改为xdt:Transform="Insert"


推荐阅读