我有一个带有2个转换的web.config - 用于调试和发布。
的web.config:
<connectionStrings>
<clear />
<add name="StrName" connectionString="data source=.\sqlexpress;User Id=sa;Password=pass;Database=SocialBot;"
providerName="System.Data.SqlClient" />
</connectionStrings>
我刚刚复制了给定的示例,并用StrName替换了名称。我最终得到了:
<add name="StrName" connectionString="$(ReplacableToken_SocialBotConnectionString-Web.config Connection String_0)"
providerName="System.Data.SqlClient" />
ReplacableToken_到底是什么?
我有另一个项目,它没有任何问题。
答案 0 :(得分:121)
如果像我一样,在尝试使用命令行中的msbuild自动化构建过程时遇到此问题,可以在此博客条目中找到正确的答案:
具体来说,您需要设置的参数是:
/ P:AutoParameterizationWebConfigConnectionStrings =假
这很有可能是VS在您发布到文件系统时代表您做的事情
答案 1 :(得分:26)
如果要使用Visual Studio 2010进行构建,请将以下行添加到.csproj中的配置PropertyGroup中:
<AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>
此处有更多详情: How to get rid of "$(ReplacableToken...)" in web.config completely