.NET用于开发和发布的不同应用程序设置 [英] .NET different application settings for development and release

查看:87
本文介绍了.NET用于开发和发布的不同应用程序设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS2010 C#.NET 3.5和应用程序设置(Settings.settings文件).我要为开发和生产环境设置不同的设置,而不必在检查调试模式的条件语句中乱扔我的代码.解决此问题的常用方法是什么?

I am using VS2010 C#.NET 3.5 and application settings (the Settings.settings file). What I want to do is have different settings for my development and production environments without having to litter my code with conditional statements checking for debug mode. What is the common approach to this problem?

推荐答案

或者您也可以创建单独的配置文件并调用它们:

Or you can just create separate config files and call them:

发布设置

Debug.settings

Debug.settings

然后设置条件构建事件,该事件将适当的.config文件复制到Settings.Settings

then setup conditional build events that copy the appropriate .config file to Settings.Settings


if $(ConfigurationName) == Debug xcopy debug.settings settings.settings
if $(ConfigurationName) == Release xcopy release.settings settings.settings

这篇关于.NET用于开发和发布的不同应用程序设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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