|
129 | 129 |
|
130 | 130 | <MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(NuGetConfigFile)'))" /> |
131 | 131 |
|
132 | | - <Copy |
133 | | - SourceFiles="$(OriginalNuGetConfigFile)" |
134 | | - DestinationFiles="$(NuGetConfigFile)"> |
| 132 | + <Copy SourceFiles="$(OriginalNuGetConfigFile)" |
| 133 | + DestinationFiles="$(NuGetConfigFile)"> |
135 | 134 | <Output TaskParameter="CopiedFiles" ItemName="FileWrites" /> |
136 | 135 | </Copy> |
137 | 136 | </Target> |
|
602 | 601 | DestinationFiles="$(NuGetPackageRoot)%(RecursiveDir)%(Filename)%(Extension)" |
603 | 602 | SkipUnchangedFiles="true" |
604 | 603 | Retries="5" |
| 604 | + UseHardlinksIfPossible="true" |
605 | 605 | Condition="'@(_InnerPackageCacheFiles)' != ''" /> |
606 | 606 | </Target> |
607 | 607 |
|
|
625 | 625 | Condition="'@(PrebuiltReportsToMove)' != ''" /> |
626 | 626 | </Target> |
627 | 627 |
|
| 628 | + <!-- Make a copy of project.assets.json files for prebuilt report generation. --> |
| 629 | + <Target Name="BackupProjectAssetsJsonFiles" |
| 630 | + Condition="'$(DotNetBuildSourceOnly)' == 'true'"> |
| 631 | + <PropertyGroup> |
| 632 | + <ProjectAssetsJsonBackupDir>$([MSBuild]::NormalizeDirectory('$(BaseIntermediateOutputPath)', 'project-assets-json'))</ProjectAssetsJsonBackupDir> |
| 633 | + </PropertyGroup> |
| 634 | + |
| 635 | + <ItemGroup> |
| 636 | + <ProjectAssetsJsonFile Include="$(RepoArtifactsDir)**/project.assets.json" /> |
| 637 | + </ItemGroup> |
| 638 | + |
| 639 | + <Copy SourceFiles="@(ProjectAssetsJsonFile)" |
| 640 | + DestinationFolder="$(ProjectAssetsJsonBackupDir)%(RecursiveDir)" |
| 641 | + UseHardlinksIfPossible="true" |
| 642 | + SkipUnchangedFiles="true" |
| 643 | + Condition="'@(ProjectAssetsJsonFile)' != ''" /> |
| 644 | + </Target> |
| 645 | + |
628 | 646 | <Target Name="CleanupRepo" |
629 | 647 | Inputs="$(MSBuildProjectFullPath)" |
630 | 648 | Outputs="$(BaseIntermediateOutputPath)CleanupRepo.complete" |
| 649 | + DependsOnTargets="BackupProjectAssetsJsonFiles" |
631 | 650 | Condition="'$(IsUtilityProject)' != 'true' and |
632 | 651 | '$(CleanWhileBuilding)' == 'true' and |
633 | 652 | Exists('$(RepoArtifactsDir)')"> |
|
646 | 665 | IgnoreStandardErrorWarningFormat="true" |
647 | 666 | IgnoreExitCode="true" /> |
648 | 667 |
|
| 668 | + <Message Text="DirSize After Building $(RepositoryName)" Importance="High" Condition="'$(BuildOS)' != 'windows'" /> |
| 669 | + <Exec Command="df -h $(RepoRoot)" Condition="'$(BuildOS)' != 'windows'" /> |
| 670 | + |
| 671 | + <!-- Cleanup the entire repo artifacts dir. Ignore failures as this is best effort. |
| 672 | + Don't use Removedir as ContinueOnError on it doesn't work when using warnaserror/TreatWarningsAsErrors. --> |
649 | 673 | <PropertyGroup> |
650 | | - <BuildObjDir>$([MSBuild]::NormalizeDirectory('$(ProjectDirectory)', 'artifacts', 'buildObj'))</BuildObjDir> |
| 674 | + <RepoCleanCommand Condition="'$(BuildOS)' == 'windows'">rmdir "$(RepoArtifactsDir.TrimEnd('\'))" /s /q</RepoCleanCommand> |
| 675 | + <RepoCleanCommand Condition="'$(BuildOS)' != 'windows'">rm -rf "$(RepoArtifactsDir)"</RepoCleanCommand> |
651 | 676 | </PropertyGroup> |
652 | 677 |
|
653 | | - <ItemGroup> |
654 | | - <ObjFilesToCopy Include="$(RepoArtifactsDir)**/project.assets.json" /> |
655 | | - </ItemGroup> |
656 | | - |
657 | | - <!-- Make a copy of project.assets.json files --> |
658 | | - <Copy SourceFiles="@(ObjFilesToCopy)" |
659 | | - DestinationFolder="$(BuildObjDir)%(RecursiveDir)" |
660 | | - Condition="'@(ObjFilesToCopy)' != ''" /> |
661 | | - |
662 | | - <ItemGroup> |
663 | | - <DirsToDelete Include="$([System.IO.Directory]::GetDirectories('$(RepoArtifactsDir)'))" /> |
664 | | - |
665 | | - <DirsToDeleteWithTrailingSeparator Include="$([MSBuild]::EnsureTrailingSlash('%(DirsToDelete.Identity)'))" /> |
666 | | - <DirsToDeleteWithTrailingSeparator Remove="$(BuildObjDir)" /> |
667 | | - </ItemGroup> |
668 | | - |
669 | | - <Message Text="DirSize After Building $(RepositoryName)" Importance="High" Condition="'$(BuildOS)' != 'windows' and '@(DirsToDeleteWithTrailingSeparator)' != ''" /> |
670 | | - <Exec Command="df -h $(RepoRoot)" Condition="'$(BuildOS)' != 'windows' and '@(DirsToDeleteWithTrailingSeparator)' != ''" /> |
671 | | - |
672 | | - <!-- Cleanup everything else. Ignore errors as out-of-band build servers don't reliably shut down, even with the build-server shutdown command. |
673 | | - https://github.com/dotnet/source-build/issues/4175 tracks a long term fix. --> |
674 | | - <RemoveDir Directories="@(DirsToDeleteWithTrailingSeparator)" ContinueOnError="true" /> |
| 678 | + <Exec Command="$(RepoCleanCommand)" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" /> |
675 | 679 |
|
676 | | - <Message Text="DirSize After CleanupRepo $(RepositoryName)" Importance="High" Condition="'$(BuildOS)' != 'windows'and '@(DirsToDeleteWithTrailingSeparator)' != ''" /> |
677 | | - <Exec Command="df -h $(RepoRoot)" Condition="'$(BuildOS)' != 'windows'and '@(DirsToDeleteWithTrailingSeparator)' != ''" /> |
| 680 | + <Message Text="DirSize After CleanupRepo $(RepositoryName)" Importance="High" Condition="'$(BuildOS)' != 'windows'" /> |
| 681 | + <Exec Command="df -h $(RepoRoot)" Condition="'$(BuildOS)' != 'windows'" /> |
678 | 682 |
|
679 | 683 | <MakeDir Directories="$(BaseIntermediateOutputPath)" /> |
680 | 684 | <Touch Files="$(BaseIntermediateOutputPath)CleanupRepo.complete" AlwaysCreate="true"> |
|
720 | 724 | <ExtractedToolFiles Include="$(SourceBuiltSdksDir)%(_ToolPackage.Id)/**/*netcore*/*.dll" /> |
721 | 725 | </ItemGroup> |
722 | 726 |
|
723 | | - <Copy SourceFiles="@(ExtractedToolFiles)" DestinationFolder="$(SourceBuiltSdksDir)/" /> |
| 727 | + <Copy SourceFiles="@(ExtractedToolFiles)" |
| 728 | + DestinationFolder="$(SourceBuiltSdksDir)/" |
| 729 | + UseHardlinksIfPossible="true" /> |
724 | 730 |
|
725 | 731 | <MakeDir Directories="$(BaseIntermediateOutputPath)" /> |
726 | 732 | <Touch Files="$(BaseIntermediateOutputPath)ExtractToolPackage.complete" AlwaysCreate="true"> |
|
0 commit comments