C# – How to add config transform for custom config file

asp.netcnetvisual studioweb.config

Visual Studio natively supports adding custom config transforms for web.config. Is there a way to do the same thing for a custom config file? For instance, the shop I'm at has an EnvironmentConfigs directory in the root of the project and there are custom appSettings.config and connectionStrings.config files. Is there a way to do the same thing that web.config does and add appSettings.Release.config and connectionStrings.Release.config transformation files that will transform them on publish?

Best Answer

I'm not sure about config's like that, but check out the Slow Cheetah extension in VS2010. You can install it by going to the Tools > Extension Manager and search the Online Gallery. It adds the ability to use config transforms for App.Config's and possibly will work in the scenario you describe. It adds a lot of transform functionality in general (even to web.config's) so it's a great tool to use. Out of the box, VS2010 will not do that, though.

Edit: According to the description for SlowCheetah: "This package enables you to transform app.config or any other XML file based on the build configuration". So yes, it seems it will do what you need...