I try to use MSBuild to delete some files in the OutDir but it never works. I have to use an Exec instead.
<Target Name="ResetPackages" BeforeTargets="DispatchToInnerBuilds">
<Exec Command = "del /Q /F $(OutDir)*.extension/>
<Delete Files="$(OutDir)*.extension" />
</Target>
The Exec command works while Delete does nothing. Can anybody explain me why ?
You need to pass an ItemGroup to Delete
if you want wildcards to be expanded:
<Project>
<Target Name="Test">
<ItemGroup>
<_FilesToDelete Include="$(OutDir)*.extension"/>
</ItemGroup>
<Delete Files="@(_FilesToDelete)"/>
</Target>
</Project>
(The Exec-Task runs CMD.EXE
which then does the wildcard expansion.)