开发者

What's a good solution to have a configuration settings specific to a machine?

HI, I want to have set configuration settings for a unit test project that is only relative for one machine ( i.e build machine). So for e.g. is the unit test project is being comp开发者_开发知识库iled on a developer machine then use settings A from App.config, if it's compiled on a build machine then use settings B from App.config. Is there a best practice for this sort of things?


In the appSettings tag, you can add an attribute like:

<appSettings file="moreSettings.config">

Inside the 'moreSettings.config' file, you create an tag that contains key-value pairs for any of the key-value pairs that you want to override from the main App.config file.


you can use conditional compilation symbols (just same as macro in C/C++) also...


Well, i guess you could check the hostname (this should be possible in almost any language or build environment) and depending on that decide what settings to use.

However i would not advise you to "automagicly" decide to do a developer/debug build. But rather i would suggest you provide a "switch" either on comandline or in a config file. Which you than explicitly enable in your setup on the development/test machine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜