i have been looking around how to create web.config transformation when using tfs build.
there are 3 options:
- Use publish profile - this is done by creating a publish profile (right click on the project and select publish), then add to the build definition, "MSBuild Arguments"
- Add "xmlTransform" task to the csproj - open the csproj file for edit (Unload and edit) and add right before the end
<Target Name="TransformConfigFiles" AfterTargets="AfterBuild" Condition="'$(TransformConfigFiles)'=='true'"> <ItemGroup> <DeleteAfterBuild Include="$(WebProjectOutputDir)Web.*.config" /> </ItemGroup> <TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)Web.config" /> <Delete Files="@(DeleteAfterBuild)" /> </Target>in order to control this, you need to add to the build definition, "MSBuild Arguments"
/p: TransformConfigFiles=true
- Force MSBuild to run Config transformation - this is done by add to the build definition, "MSBuild Arguments"
just don't forge, if you are using TFS2013 with old build templates (2010/2012) you will also need to add "/p:VisualStudioVersion=12.0"