Different config files in C# project
It is almost certain that you would need different configuration for different environments. Here’s one way to maintain separate config files.
This should work for any number of configurations in the project- Release, Debug and whatever else custom configurations exist.
- Externally open
ProjectName.csprojusing a text editor. - Import below after the last import. This is for the
TransformXmltask in step 3.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.targets" />- Add this task as BeforeBuild target like so:
<Target Name="BeforeBuild"> <TransformXml Source="App.$(Configuration).config" Transform="App.config" Destination="App.config" /> </Target>