Skip to content

Commit

Permalink
Clean intermediate dirs in pipeline builds to manage disk space (#871)
Browse files Browse the repository at this point in the history
* clean up obj dir with each project build

* conditional CleanIntermediateDirs target
  • Loading branch information
Scottj1s authored Jun 11, 2021
1 parent 334cb0e commit d4a60fd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<BuildOutDir Condition="'$(BuildOutDir)'==''">$([MSBuild]::NormalizeDirectory('$(SolutionDir)_build', '$(BuildPlatform)', '$(Configuration)'))</BuildOutDir>
<CsWinRTPath>$([MSBuild]::NormalizeDirectory('$(BuildOutDir)', 'cswinrt', 'bin'))</CsWinRTPath>
<CsWinRTPath Condition="'$(Platform)'=='ARM' or '$(Platform)'=='ARM64'">$([MSBuild]::NormalizeDirectory('$(SolutionDir)_build', 'x86', '$(Configuration)', 'cswinrt', 'bin'))</CsWinRTPath>
<CsWinRTInteropMetadata Condition="'$(CsWinRTInteropMetadata)' == ''">$(CsWinRTPath)..\obj\merged\WinRT.Interop.winmd</CsWinRTInteropMetadata>
<CsWinRTInteropMetadata Condition="'$(CsWinRTInteropMetadata)' == ''">$(CsWinRTPath)WinRT.Interop.winmd</CsWinRTInteropMetadata>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.vcxproj' or '$(MSBuildProjectExtension)' == '.wapproj'">
Expand Down
4 changes: 4 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
<Error Condition="!Exists('$(SolutionDir)TestWinRT')" Text="This solution requires the TestWinRT repo, which is missing. Please run build.cmd from a Visual Studio command prompt." />
</Target>

<Target Name="CleanIntermediateDirs" Condition="'$(CleanIntermediateDirs)'=='true'" AfterTargets="Build">
<RemoveDir Directories="$(IntDir)" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions src/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ if not "%cswinrt_label%"=="" goto %cswinrt_label%
:restore
rem When a preview nuget is required, update -self doesn't work, so manually update
if exist %nuget_dir%\nuget.exe (
%nuget_dir%\nuget.exe | findstr 5.8.0 >nul
%nuget_dir%\nuget.exe | findstr 5.9 >nul
if ErrorLevel 1 (
echo Updating to nuget 5.8.0
echo Updating to nuget 5.9
rd /s/q %nuget_dir% >nul 2>&1
)
)
Expand Down
8 changes: 6 additions & 2 deletions src/cswinrt/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
</PropertyGroup>

<!--Workaround for MidlRT nupkg expecting project to publish $(RootNamespace).winmd-->
<Target Name="CopyWinRTInteropWinMD" Inputs="$(CsWinRTInteropMetadata)" Outputs="$(MidlRTProjectWinMD)">
<Target Name="CopyWinRTInteropWinMD" Inputs="$(CsWinRTPath)..\obj\merged\WinRT.Interop.winmd" Outputs="$(MidlRTProjectWinMD);$(CsWinRTInteropMetadata)">
<Copy UseHardlinksIfPossible="$(MidlRTUseHardlinksIfPossible)"
SkipUnchangedFiles="$(MidlRTSkipUnchangedFiles)"
SourceFiles="$(CsWinRTInteropMetadata)"
SourceFiles="$(CsWinRTPath)..\obj\merged\WinRT.Interop.winmd"
DestinationFiles="$(MidlRTProjectWinMD)" />
<Copy UseHardlinksIfPossible="$(MidlRTUseHardlinksIfPossible)"
SkipUnchangedFiles="$(MidlRTSkipUnchangedFiles)"
SourceFiles="$(CsWinRTPath)..\obj\merged\WinRT.Interop.winmd"
DestinationFiles="$(CsWinRTInteropMetadata)" />
</Target>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
Expand Down

0 comments on commit d4a60fd

Please sign in to comment.