Skip to content

Instantly share code, notes, and snippets.

@swax
Created June 25, 2025 16:34
Show Gist options
  • Save swax/6fff14be5042a1ebaeba3d154551b282 to your computer and use it in GitHub Desktop.
Save swax/6fff14be5042a1ebaeba3d154551b282 to your computer and use it in GitHub Desktop.
Example of deleting folders with MSBuild
<Project Sdk="Microsoft.NET.Sdk">
<Target Name="CleanupDashDirs" AfterTargets="Publish">
<ItemGroup>
<DashFiles Include="$(PublishDir)..\**\*-*\**" Exclude="**\*en-us*\**" />
<DashDirs Include="@(DashFiles->'%(RootDir)%(Directory)')" />
<!-- Remove duplicates -->
<UniqueDashDirs Include="@(DashDirs->Distinct())" />
</ItemGroup>
<Message Importance="High" Text="PublishDir = $(PublishDir)" />
<Message
Importance="High"
Text="🗑️ CleanupDashDirs: will remove these dirs -> @(UniqueDashDirs)" />
<RemoveDir Directories="@(UniqueDashDirs)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment