Separate Microsoft.TestCommon more (#400)

- pre-restore and prebuild the project before anything that depends on it
  - avoid references from other test projects doing any real work
- make ordering even more explicit
  - avoid confusion between batching builds and `$(BuildInParallel)`
- turns out this also reduces the number of double writes binary logs show significantly
This commit is contained in:
Doug Bunting 2023-03-15 15:20:25 -07:00 коммит произвёл GitHub
Родитель 6949d439be
Коммит 509661e54f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 35 добавлений и 9 удалений

Просмотреть файл

@ -52,14 +52,26 @@
<Exec Command='"$(NuGetExe)" restore .nuget\packages.config -PackagesDirectory packages -NonInteractive -Verbosity quiet' /> <Exec Command='"$(NuGetExe)" restore .nuget\packages.config -PackagesDirectory packages -NonInteractive -Verbosity quiet' />
</Target> </Target>
<ItemGroup>
<_Testing_NetStandard1_3 Include="true;false" />
</ItemGroup>
<Target Name="RestorePackages" DependsOnTargets="DownloadNuGet"> <Target Name="RestorePackages" DependsOnTargets="DownloadNuGet">
<ItemGroup>
<_ToRestore Include="Runtime.sln" />
<_ToRestore Include="test\Microsoft.TestCommon\Microsoft.TestCommon.csproj"
AdditionalProperties="Testing_NetStandard1_3=true" />
</ItemGroup>
<Message Text="%0ARestoring NuGet packages..." Importance="High" /> <Message Text="%0ARestoring NuGet packages..." Importance="High" />
<MSBuild Projects="@(_ToRestore)" Targets="Restore"
<!--
Pre-restore Microsoft.TestCommon due to the many dependencies on this project. Batch it to cover the full
set of references. Remove $(Platform) to avoid 'Any CPU' appearing in output paths. Can always restore in
parallel because $(Testing_NetStandard1_3) changes both obj/ and bin/ folders entirely.
-->
<MSBuild Projects="test\Microsoft.TestCommon\Microsoft.TestCommon.csproj" Targets="Restore"
BuildInParallel="true"
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
RestorePackagesConfig=true;VisualStudioVersion=$(VisualStudioVersion);
Testing_NetStandard1_3=%(_Testing_NetStandard1_3.Identity)"
RemoveProperties="Platform" />
<MSBuild Projects="Runtime.sln" Targets="Restore"
BuildInParallel="$(RestoreInParallel)" BuildInParallel="$(RestoreInParallel)"
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled); Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
RestorePackagesConfig=true;VisualStudioVersion=$(VisualStudioVersion)" /> RestorePackagesConfig=true;VisualStudioVersion=$(VisualStudioVersion)" />
@ -79,14 +91,28 @@
</Target> </Target>
<Target Name="Build" DependsOnTargets="RestoreSkipStrongNames;RestorePackages;BuildTools"> <Target Name="Build" DependsOnTargets="RestoreSkipStrongNames;RestorePackages;BuildTools">
<!-- we need to batch the solution files since they both build Microsoft.TestCommon --> <Error Condition=" '$(CodeAnalysis)' == 'true' and '$(Configuration)' == 'Release' "
<Error Condition=" '$(CodeAnalysis)' == 'true' and '$(Configuration)' == 'Release' " Text="Unable to run code analysis in Release configuration. Release assemblies do not include SuppressMessage attributes (so code analysis would always fail with the errors that are normally suppressed)." /> Text="Unable to run code analysis in Release configuration. Release assemblies do not include SuppressMessage attributes (so code analysis would always fail with the errors that are normally suppressed)." />
<MakeDir Directories="bin\$(Configuration)" /> <MakeDir Directories="bin\$(Configuration)" />
<!--
Prebuild Microsoft.TestCommon due to the many dependencies on this project. Batch it to cover the full
set of references. Remove $(Platform) to avoid 'Any CPU' appearing in output paths. Can always build in
parallel because $(Testing_NetStandard1_3) changes both obj/ and bin/ folders entirely.
-->
<MSBuild Projects="test\Microsoft.TestCommon\Microsoft.TestCommon.csproj" Targets="Build"
BuildInParallel="true"
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
VisualStudioVersion=$(VisualStudioVersion);
Testing_NetStandard1_3=%(_Testing_NetStandard1_3.Identity)"
RemoveProperties="Platform" />
<MSBuild <MSBuild
Projects="Runtime.sln" Projects="Runtime.sln"
BuildInParallel="$(BuildInParallel)" BuildInParallel="$(BuildInParallel)"
Targets="Build" Targets="Build"
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);VisualStudioVersion=$(VisualStudioVersion)" /> Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
VisualStudioVersion=$(VisualStudioVersion)" />
</Target> </Target>
<Target Name="UnitTest" DependsOnTargets="Build;PrintTestRunSummary" /> <Target Name="UnitTest" DependsOnTargets="Build;PrintTestRunSummary" />