Question

I have a C# class library project with some settings in Settings.settings. I need to be able to change these settings at build time based on the configuration (Debug, Release, etc.).

It's fairly straightforward to add a pre-build event to copy Settings.<configuration>.settings to Settings.settings, but as it turns out - this doesn't help! The settings are taken from Settings.Designer.cs which is generated from Settings.settings as soon as you save your changes (i.e. at code edit time).

Is there a way to regenerate Settings.Designer.cs from Settings.settings at compile time? Or is this the wrong way to go about modifying configuration settings?

Was it helpful?

Solution

The Settings.Designer.cs is generated by the IDE, not MSBuild. So, no, changing that file at compile time won't have any effect. You didn't document your question well enough to offer the best alternative, but it sure sounds like using a setting wasn't the correct choice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top