Monday, November 12, 2012

XML Transformation on MSBuild TFS 2010

Many thanks to http://kjdaly.com/Blog/Details/5 Blog ----


<Target Name="BeforeBuild">
</Target>
<!--<Target Name="AfterBuild">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
</Target>
-->    <Target Name="AfterBuild" Condition="$(IsAutoBuild)=='True'">
     <ItemGroup>
     <DeleteAfterBuild Include="$(WebProjectOutputDir)\Web.*.config" />
    </ItemGroup>
    <TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)\Web.config"/>
   <Delete Files="@(DeleteAfterBuild)" />
  </Target>
</Project>

Assuming you have saved and checked in your project file and are in the process of creating a build definition, on the Process step of your build definition you will find under the Advanced heading a field labeled “MSBuild Arguments”. Enter the value /p:IsAutoBuild=”True”.

Simple GOTCHA, be sure to check in the PROJECT File back to Source Control before testing (DUH!)
Post a Comment