2

Greetings StackOverflow,

In past projects I've gotten used to using the Settings Designer in Visual Studio to make settings files. This has worked well in the past. In my latest project I have a desire to have multiple version, a.k.a. profiles, of the same Settings class, one with production/default values for all the properties and one with test values.

While in search to see if this is possible I noticed that in the XML for the Settings.settings file there are multiple hints that having multiple setting profiles might be possible. For instance in the Settings.settings file the <SettingsFile> tag has a CurrentProfile attribute which is always set to CurrentProfile="(Default)". Inside of that tag there is an empty tag called <Profile />. Lastly the <Value> tag for each setting has a Profile attribute that usually shows Profile="(Default)".

Now, I've tried looking to what the <Profile /> tag is all about and whether I can use it for something but none of my searches have come up with anything.

Ultimately I want to know whether there is a way to have different profiles of the same Settings class, each with it's own default values, so that I can use it might show up like this in my code:

Properties.Settings defaultSettings = Properties.Settings.Default;
Properties.Settings testSettings = Properties.Settings.Test;

If anyone knows where to find the XML Schema for the settings file or if what I am asking for is possible please let me know.

4

1 回答 1

1

我使用Enterprise 库为不同的开发环境设置不同的配置。这需要一点时间来适应,但是有一个很好的配置工具可以读取配置文件并显示您的所有应用程序设置。您可以为计划使用的每个环境创建增量文件。我将Merge Configuration可执行文件添加到项目中的lib文件夹中,并在其顶部添加了一些构建事件以在构建时进行合并,以便文件自动准备好部署:

"$(ProjectDir)lib\MergeConfiguration.exe" "$(ProjectDir)web.config" "$(ProjectDir)lib\Delta_Dev.dconfig" "$(ProjectDir)Configurations\web.config-dev.config"
于 2012-07-25T17:43:00.570 回答