如何使用Visual Studio网站项目进行Web.config转换?

问题描述:

似乎不可能更改Visual的生成配置Studio 2010网站项目(与Visual Studio Web应用程序相对),更改构建配置是启用Web.config转换的关键部分(除了调试以外,无法将配置更改为其他任何内容).

It doesn't seem to be possible to change the Build Configuration of Visual Studio 2010 Website Projects (as opposed to Visual Studio Web Applications), and changing the Build Configuration is a key part of enabling Web.config transformations (it's not possible to change the configuration to anything except Debug).

如果无法更改生成配置,如何使Web.config转换与Visual Studio 2010网站项目一起使用?

How do I get Web.config transformations to work with Visual Studio 2010 Website projects if it's not possible to change the Build Configuration?

我在此处找到了一篇不错的博客文章,描述了解决方案: http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/

I found a pretty good blog post describing a solution to this here: http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/

简而言之:在包含该网站的解决方案中创建一个空项目(只要它不是另一个网站项目).空项目将使您可以通过其项目文件访问msbuild,这将使您可以在网站web.config上执行转换.

In short: create an empty project (as long as it is not another website project) in your solution that contains the website. The empty project will give you access to msbuild through its project file, which will allow you to perform transforms on your website web.config.