Search code examples
msbuildmsbuild-task

MSBuild remove files on clean


I have the following target that gets called AfterBuild

<Target Name="CopyAppDeployableArtifacts">
    <ItemGroup>
      <MyFiles Include="App_DeployableArtifacts\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(MyFiles)" DestinationFiles="@(MyFiles->'$(OutputPath)\%(RecursiveDir)%(Filename)%(Extension)')" />
  </Target>

I've noticed that doing a clean of my solution leaves folders that get copied by this command in the bin.

What is the best way to do a reverse of this copy and have those folders removed upon cleaning?


Solution

  • Extend the built in clean functionality of msbuild, See Sayeds Blog:http://www.sedodream.com/PermaLink,guid,670b78b1-4968-46b1-905b-3ae903f3d9cb.aspx