Search code examples
.netconfigurationapp-configappsettingsslowcheetah

.Net config files, what if I want only SOME app settings to be in an external config file?


I have an app.config file, with app settings like this:

<appSettings>
  <add key="setting1" value="1"/>
  <add key="setting2" value="2"/>
  <add key="setting3" value="3"/>
</appsettings>

What if I wanted to move setting2 and setting3 to an external config file "prod.config", but wanted to keep setting1 in the root config file? I tried doing this:

<appSettings configSource="prod.config">
  <add key="setting1" value="1"/>
</appsettings>

However, this causes my app to fail. It succeeds if I move setting1 into the prod.config file. How can I get this working?


Solution

  • UPDATE 01/09/2012 - I started using Team Build for the project in the post I referenced (below) and didn't want to install the Windows SDK on my build machine. I did some research and stumbled across SlowCheetah, which is the way to go for this. There is also a blog post for getting this up and running with Team Build.


    Seeing prod.config makes me think you may be trying to manage settings based on environments. If that's the case, you may want to explore config file transforms which do just that. You can find links to get you started here.