使用Visual Studio 2012进行部署时卸下的ConnectionString(Remov

2019-08-16 22:48发布

I'm working on a project with 2 web applications, one being hosted as long running process (with appfabric), the other is just a normal MVC application. They share same datacontext, thus same connectionString. The appfabric application is deployed as a child application of the main, taking advantage of the web.config inheritance (we don't want connectionstring to be duplicated in web config)

My problem is that with the new Visual Studio 2012 wizard for publishing, the connectionString are automatically added, even when I untick the "Use this connection string at runtime" box.

I also try to use web config transform like this:

  <connectionStrings>
      <add xdt:Transform="RemoveAll" />
  </connectionStrings>

But connection string are still on my web config after publishing.

Any suggestions ? I'm thinking about removing completely the web config for that child application but it's not ideal.

Answer 1:

答案可以在这里找到: Web部署/发布时增加一个未知的连接字符串?

通过编辑XML添加这个项目属性为的.csproj文件:

<Project>
    <PropertyGroup>

         <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>

   ...
    </PropertyGroup>
...
</Project>


文章来源: Removing ConnectionString when deploying with Visual Studio 2012