繁体   English   中英

使用web.config转换时,会变得像web.config文件ReplacableToken_中的此连接字符串吗?

[英]Getting like this connection string in the web.config file ReplacableToken_ when using web.config transform?

我有2种不同的服务器,例如开发和生产。 因此,我尝试了更改后的动态连接字符串和一些键。 我喜欢这个2 web.config文件。

 1) Web.Develop.Config
 2) Web.Production.Config

现在在我的web.config文件中,我喜欢此连接字符串和一些键。

 <connectionStrings>
  <add name="DefaultConnection" connectionString="localhost" />
 </connectionStrings>
 <add key="Email" value="abc@gmail.com" />

现在,在我的web.Develop.config文件中,像这样设置的连接字符串和一些键。

  <add name="DefaultConnection"
    connectionString="develop"
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>

       <add key="Email" value="develop@gamil.com" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />

现在在我的web.Producation.config文件中,像这样设置的连接字符串和一些键。

  <add name="DefaultConnection"
  connectionString="producation"
  xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>

    <add key="Email" value="producation@gamil.com" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />

因此,现在我可以使用在线VSTS进行构建和发布,并且可以在开发服务器上使用连接字符串中的web.config文件进行更改。 就像下面的这个节目

  <connectionStrings>
    <add name="DefaultConnection" connectionString="$(ReplacableToken_develop- 
    Web.config Connection String_0)" />
  </connectionStrings>

但是,是的,我的电子邮件已更改,并且我获得了开发服务器的正确电子邮件地址。

因此,谁知道如何针对web.config文件中动态更改的连接字符串解决此问题? 请帮我。

尝试以下

<add name="DefaultConnection"
connectionString="develop connection string"
xdt:Transform="Replace" xdt:Locator="Condition(@name='DefaultConnection')"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM