Rubans
Rubans

Reputation: 4488

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 compiled 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?

Upvotes: 0

Views: 74

Answers (3)

snies
snies

Reputation: 3521

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.

Upvotes: 0

smencer
smencer

Reputation: 1053

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.

Upvotes: 2

Mihir Mehta
Mihir Mehta

Reputation: 13833

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

Upvotes: 0

Related Questions