在使用 web.config 转换时,ReplacableToken_ web.config 文件中喜欢这个连接字符串



我有 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" />

现在在我的网络上。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)" />

现在在我的网络上。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')"/>

最新更新