Monday, March 26, 2007

C# Console App to Update Machine.config

I store proprietary information in our company's web servers' Machine.config's in order to manipulate the behavior of multiple applications. E.G., an appSetting determines whether the current machine is used for shared development, integration, pre-production testing, or production.

Unfortunately, I am not an administrator on the servers. No, we have outsourced that privilege to a vendor without accountability. Sound like an accident waiting to happen? That's a story for another day...

Anyway I can send a ticket to their help desk to have someone add the <appsettings> section if it doesn't exist, and then add my "Environment" key. But how do I trust that the person who picks up the ticket knows the first thing about where the appSettings section goes within Machine.config or its case-sensitive nature? I CAN'T.

The following is code for a console app that will update Machine.config according to your command line arguments:

Code snippet moved to my Windows Live Spaces Blog, for better readability.

1 comment:

site said...

This can't really work, I believe like this.