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
<Project ToolsVersion="4.0" DefaultTargets="BuildWithConfig" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
And then add a new target
<Target Name="BuildWithConfig">
<CallTarget Targets="Build"/>
<CallTarget Targets="TransformWebConfig"/>
</Target>
And then run
MSBuild "Solution.sln" /p:Configuration=Release
And the file will be output to ...\WebProject\obj\Release\TransformWebConfig\transformed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With