Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nul800sebastiaan
Created May 5, 2012 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nul800sebastiaan/2601426 to your computer and use it in GitHub Desktop.
Save nul800sebastiaan/2601426 to your computer and use it in GitHub Desktop.
Transform all web.config file
<Project ToolsVersion="4.0" DefaultTargets="Transform" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml" AssemblyFile="Tools\Microsoft.Web.Publishing.Tasks.dll"/>
<PropertyGroup>
<SitePath>$(MSBuildProjectDirectory)\..\..\Website</SitePath>
<WebConfigTransformFile>Web.Transform.config</WebConfigTransformFile>
<OutputFolder>$(MSBuildProjectDirectory)\..\Transformed</OutputFolder>
<StackTraceEnabled>False</StackTraceEnabled>
</PropertyGroup>
<Target Name="Transform">
<!-- discover the files to transform -->
<ItemGroup>
<FilesToTransform Include="$(SitePath)\**\web.config"/>
</ItemGroup>
<!-- Ensure all target directories exist -->
<MakeDir Directories="$(OutputFolder)"/>
<MakeDir Directories="@(FilesToTransform->'$(OutputFolder)\%(RecursiveDir)')"/>
<!-- TransformXml only supports single values for source/transform/destination so use %(FilesToTransform.Identity) to send only 1 value to it -->
<TransformXml Source="%(FilesToTransform.Identity)"
Transform="$(WebConfigTransformFile)"
Destination="@(FilesToTransform->'$(OutputFolder)\%(RecursiveDir)\%(Filename)%(Extension)')" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment