Skip to content

Commit 509661e

Browse files
authored
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
1 parent 6949d43 commit 509661e

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

Runtime.msbuild

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,26 @@
5252
<Exec Command='"$(NuGetExe)" restore .nuget\packages.config -PackagesDirectory packages -NonInteractive -Verbosity quiet' />
5353
</Target>
5454

55+
<ItemGroup>
56+
<_Testing_NetStandard1_3 Include="true;false" />
57+
</ItemGroup>
58+
5559
<Target Name="RestorePackages" DependsOnTargets="DownloadNuGet">
56-
<ItemGroup>
57-
<_ToRestore Include="Runtime.sln" />
58-
<_ToRestore Include="test\Microsoft.TestCommon\Microsoft.TestCommon.csproj"
59-
AdditionalProperties="Testing_NetStandard1_3=true" />
60-
</ItemGroup>
6160
<Message Text="%0ARestoring NuGet packages..." Importance="High" />
62-
<MSBuild Projects="@(_ToRestore)" Targets="Restore"
61+
62+
<!--
63+
Pre-restore Microsoft.TestCommon due to the many dependencies on this project. Batch it to cover the full
64+
set of references. Remove $(Platform) to avoid 'Any CPU' appearing in output paths. Can always restore in
65+
parallel because $(Testing_NetStandard1_3) changes both obj/ and bin/ folders entirely.
66+
-->
67+
<MSBuild Projects="test\Microsoft.TestCommon\Microsoft.TestCommon.csproj" Targets="Restore"
68+
BuildInParallel="true"
69+
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
70+
RestorePackagesConfig=true;VisualStudioVersion=$(VisualStudioVersion);
71+
Testing_NetStandard1_3=%(_Testing_NetStandard1_3.Identity)"
72+
RemoveProperties="Platform" />
73+
74+
<MSBuild Projects="Runtime.sln" Targets="Restore"
6375
BuildInParallel="$(RestoreInParallel)"
6476
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
6577
RestorePackagesConfig=true;VisualStudioVersion=$(VisualStudioVersion)" />
@@ -79,14 +91,28 @@
7991
</Target>
8092

8193
<Target Name="Build" DependsOnTargets="RestoreSkipStrongNames;RestorePackages;BuildTools">
82-
<!-- we need to batch the solution files since they both build Microsoft.TestCommon -->
83-
<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)." />
94+
<Error Condition=" '$(CodeAnalysis)' == 'true' and '$(Configuration)' == 'Release' "
95+
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)." />
8496
<MakeDir Directories="bin\$(Configuration)" />
97+
98+
<!--
99+
Prebuild Microsoft.TestCommon due to the many dependencies on this project. Batch it to cover the full
100+
set of references. Remove $(Platform) to avoid 'Any CPU' appearing in output paths. Can always build in
101+
parallel because $(Testing_NetStandard1_3) changes both obj/ and bin/ folders entirely.
102+
-->
103+
<MSBuild Projects="test\Microsoft.TestCommon\Microsoft.TestCommon.csproj" Targets="Build"
104+
BuildInParallel="true"
105+
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
106+
VisualStudioVersion=$(VisualStudioVersion);
107+
Testing_NetStandard1_3=%(_Testing_NetStandard1_3.Identity)"
108+
RemoveProperties="Platform" />
109+
85110
<MSBuild
86111
Projects="Runtime.sln"
87112
BuildInParallel="$(BuildInParallel)"
88113
Targets="Build"
89-
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);VisualStudioVersion=$(VisualStudioVersion)" />
114+
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);
115+
VisualStudioVersion=$(VisualStudioVersion)" />
90116
</Target>
91117

92118
<Target Name="UnitTest" DependsOnTargets="Build;PrintTestRunSummary" />

0 commit comments

Comments
 (0)