-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectory.Build.targets
33 lines (27 loc) · 1.33 KB
/
Directory.Build.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<Project>
<Target Name="RemoveObjAndBinFolders" AfterTargets="Clean">
<PropertyGroup>
<ObjFolder>$(ProjectDir)$(BaseIntermediateOutputPath)</ObjFolder>
<BinFolder>$(ProjectDir)$(BaseOutputPath)</BinFolder>
<!-- Microsoft.NET.Sdk.Web sets $(BaseIntermediateOutputPath) to -->
<!-- an absolute path. Not fixed up to MsBuild 17! -->
<BaseIntermediateOutputPathFix Condition="$(BaseIntermediateOutputPath.StartsWith($(MSBuildProjectDirectory)))">$([MSBuild]::MakeRelative(
$(ProjectDir),
$(BaseIntermediateOutputPath)
))</BaseIntermediateOutputPathFix>
<ObjFolder Condition="$(BaseIntermediateOutputPath.StartsWith($(MSBuildProjectDirectory)))">$(ProjectDir)$(BaseIntermediateOutputPathFix)</ObjFolder>
</PropertyGroup>
<ItemGroup>
<ObjFiles Include="$(ObjFolder)/*.*"
Exclude="$(ObjFolder)/project.assets.json" />
<ObjSubFolders
Include="$([System.IO.Directory]::GetDirectories('$(ObjFolder)'))" />
</ItemGroup>
<!-- Remove "obj" sub folders -->
<RemoveDir Directories="@(ObjSubFolders)" ContinueOnError="true" />
<!-- Remove "obj" files (keeping necessary asset file)-->
<Delete Files="@(ObjFiles)" />
<!-- Remove "bin" folders -->
<RemoveDir Directories="$(BinFolder)" ContinueOnError="true" />
</Target>
</Project>