Visual Studio:针对调试和发布模式区分 app.config [英] Visual Studio: differentiate app.config for debug and release mode

查看:33
本文介绍了Visual Studio:针对调试和发布模式区分 app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在发布模式下构建时,有没有办法自动使用单独的 app.config?

Is there a way to automatically use a separate app.config when building in release mode?

换句话说,我想用一个 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屋!

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