I have a solution with multiple projects in it one of these projects is a web application and I would like to be able to transform the web.config using web.release.config when building the solution using MSBuild.
When I call
MSBuild “WebProject.csproj” /t:TransformWebConfig
/p:Configuration=Release
on the web project I get the transformed web.config output to …\obj\Release\TransformWebConfig\transformed\ Web.config
but when I try to call
MSBuild “Solution.sln” /t:TransformWebConfig
/p:Configuration=Release
I get an error that “TransformWebConfig does not exist in the project”. Is there a you to get this to work so it will output a transformed web.config if possible and ignore the TransformWebConfig part of the command otherwise?
The easiest way to do this seems to be to change the web projects .csproj file to
And then add a new target
And then run
And the file will be output to …\WebProject\obj\Release\TransformWebConfig\transformed