当使用 web.config 转换时 ReplaceToken _?

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

ReplaceableToken _ 是什么鬼东西?

我有另一个项目,它的工作没有问题。

20656 次浏览

If, like me, you're running up against this problem while trying to automate your build process using msbuild from the command line, the correct answer can be found in this blog entry:

http://www.zvolkov.com/clog/2010/05/18/how-to-packagepublish-web-site-project-using-vs2010-and-msbuild/

Specifically, the parameter you need to set is:

/p:AutoParameterizationWebConfigConnectionStrings=False

This is most likely what VS is doing on your behalf when you publish to the filesystem

If you want to build with Visual Studio 2010, add the following line to your configuration PropertyGroup in your .csproj:

<AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>

More details here: How to get rid of "$(ReplacableToken...)" in web.config completely