I have setup some configuration transforms in my web.config for my connectionStrings, etc. But I have separated out some areas of my web.config into separate files, ex) appSettings.config.
How can I configure Visual Studio and MSBuild to perform config transformations on these additional config files?
I have already followed the approach of the web.config to relate the files together within my web application project file, but transformations are not automatically applied.
<ItemGroup>
<Content Include="appSettings.Debug.config">
<DependentUpon>appSettings.config</DependentUpon>
</Content>
</ItemGroup>
Something that makes this a lot easier, take a look at the SlowCheetah VS add-in at ... visualstudiogallery
Here is the code that works for me:
By default the target managing the transformation (
TransformWebConfig
) works only onweb.config
file.To make it work on your
appSettings.config
file you'll have to :Build Action
of your file toContent
TransformWebConfig
withProjectConfigFileName=appSettings.config
andConfiguration=$(Configuration)
.To call MSBuild
TransformWebConfig
target forappSettings.config
just after the transformation ofweb.config
files, you need to add this at the end of your project file :