Visual Studio:针对调试和发布模式区分app.config [英] Visual Studio: differentiate app.config for debug and release mode
本文介绍了Visual Studio:针对调试和发布模式区分app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在发布模式下构建时,是否可以自动使用单独的app.config?
Is there a way to automatically use a separate app.config when building in release mode?
换句话说,我想使用一个app.config进行测试,然后使用另一个app.config进行发布.
In other words, I want to test with one app.config, and release with another.
当前,我保留一个名为app.config.production的单独副本,并在构建发布版本后手动覆盖bin \ Release \ Application.exe.config.
Currently, I keep a separate copy called app.config.production, and manually overwrite bin\Release\Application.exe.config after building for release.
推荐答案
通过上下文菜单在解决方案资源管理器中卸载项目.
Unload the project in Solution Explorer via the context menu.
通过上下文菜单编辑.csproj
文件并添加以下内容:
Edit the .csproj
file via the context menu and add this:
<PropertyGroup>
<AppConfig>App.$(Configuration).config</AppConfig>
</PropertyGroup>
这篇关于Visual Studio:针对调试和发布模式区分app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文