是否可以在不发布的情况下执行 Web.config 转换?
我正在使用 VS2010,并且我知道当我发布 Web 应用程序时,我正在使用的 Web.config 会根据构建设置进行转换。
即当我选择“调试”时,它使用我的开发 SQL 服务器,当我选择“发布”时,它使用我的生产 SQL 服务器。
我想知道的是:我可以仅使用内置的 Visual Studio 开发服务器,从“配置”下拉列表中选择“发布”,然后选择绿色的“继续”箭头 (F5),并使用转换后的 Web 运行。配置设置?
我会很高兴拥有另一个文件,例如“generic.config”(或更好:“Web.Generic.config”),它在必要时保存主代码。
I am using VS2010, and I understand that when I publish a web application, the Web.config I am using is transformed based on the build settings.
i.e. When I choose Debug, it uses my development SQL server, and when I choose Release, it uses my production SQL server.
What I want to know is: Can I, using only the built in Visual Studio Development Server, select "Release" from the Configuration drop-down, and then the green "Continue" arrow (F5), and run using the transformed Web.config settings?
I would be quite happy having another file such as "generic.config" (or better: "Web.Generic.config"), which holds the master code if necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信有一种简单的方法可以做到这一点。我本以为想要针对生产数据库在本地运行代码是不寻常的,但也许您不在企业领域,这可能正是此功能的设计目的。
另一种方法是将站点发布到服务器,然后使用远程调试来单步调试代码。
简单的
web.config
是您的本地设置和通用设置的组合。转换会调整通用数据以匹配您要部署到的环境。如果您只想快速测试 web.config 转换的结果,有一个方便的网站: http://webconfigtransformationtester.apphb.com
I don't believe there's a simple way to do this. I would have thought it's unusual to want to run code locally against a production database, but maybe you're not in Enterprise Land which is probably what this functionality was designed for.
An alternative would be to publish your site to a server, and then use Remote Debugging to step into the code.
The plain
web.config
is your local and generic settings combined. The transforms tweak the generic data to match the environment you're deploying to.There's a handy site if you just want to quickly test the results of a web.config transform: http://webconfigtransformationtester.apphb.com