如何使用 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.