开发者

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

开发者 https://www.devze.com 2022-12-24 14:05 出处:网络
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开发者_开发知识库ile

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

精彩评论

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

关注公众号