使用Visual Studio 2012进行部署时删除ConnectionString [英] Removing ConnectionString when deploying with Visual Studio 2012

查看:410
本文介绍了使用Visual Studio 2012进行部署时删除ConnectionString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含2个Web应用程序的项目,其中一个作为长时间运行的进程(使用appfabric)进行托管,另一个只是一个普通的MVC应用程序。
它们共享相同的datacontext,因此是相同的connectionString。
appfabric应用程序部署为main的子应用程序,利用web.config继承(我们不希望在web配置中复制连接字符串)

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)

我的问题是,使用新的Visual Studio 2012向导进行发布时,即使我取消勾选在运行时使用此连接字符串框,也会自动添加connectionString。

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.

有什么建议吗?我正在考虑完全删除该子应用程序的Web配置,但它并不理想。

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

推荐答案

答案可以在这里找到:
Web部署/发布是否添加了未知的连接字符串?

answer can be found here: Web Deploy / Publish is adding a unknown connection string?

通过编辑XML将此项目属性添加到.csproj文件:

Add this project property to the .csproj file by editing the XML:

<Project>
    <PropertyGroup>

         <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>

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

这篇关于使用Visual Studio 2012进行部署时删除ConnectionString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆