The above solution made an excellent starting point for me, but in the end I got the following, which does not require a copy task and does not have problems with file usage errors.
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" /> <Target Name="AfterBuild"> <TransformXml Condition="exists('$(TempBuildDir)\Web.$(Configuration).config')" Source="$(TempBuildDir)\Web.config" Destination="$(OutputPath)Web.config" Transform="$(TempBuildDir)\Web.$(Configuration).config" /> <ItemGroup> <DeleteAfterBuild Include="$(OutputPath)Web.*.config" /> </ItemGroup> <Delete Files="@(DeleteAfterBuild)"> <Output TaskParameter="DeletedFiles" PropertyName="deleted" /> </Delete> <Message Text="DELETED FILES: $(deleted)" Importance="high" /> </Target>
Bernd Dec 20 '11 at 16:35 2011-12-20 16:35
source share