Skip to content

Commit d8733c2

Browse files
mmitchedougbu
andauthored
Build time changes (#22362)
* Build time changes A few changes for build time - Don't build tests with SkipTestBuild=true and use that for official build legs. This cuts 40%-50% off the msbuild invocations for build. The longest build leg drops by about 30 mins. - Skip logging of some task parameters and their metadata. This reduces overall binlog size, which is a major contributor to build time. Unfortunately, this does not mean we can yet turn binlogs back on. This change can actually increase the overall binlog size due to logging of more project started arguments. There is another optimization for this in progress. Co-authored-by: Doug Bunting <[email protected]>
1 parent e7ca49c commit d8733c2

File tree

10 files changed

+60
-13
lines changed

10 files changed

+60
-13
lines changed

.azure/pipelines/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ variables:
3535
- name: _UseHelixOpenQueues
3636
value: 'true'
3737
- name: _BuildArgs
38-
value: ''
38+
value: '/p:SkipTestBuild=true'
3939
- name: _PublishArgs
4040
value: ''
4141
- name: _SignType
@@ -66,6 +66,7 @@ variables:
6666
- name: _BuildArgs
6767
value: /p:TeamName=$(_TeamName)
6868
/p:OfficialBuildId=$(Build.BuildNumber)
69+
/p:SkipTestBuild=true
6970
- name: _SignType
7071
value: real
7172

@@ -81,7 +82,7 @@ variables:
8182

8283
- ${{ if in(variables['Build.Reason'], 'PullRequest') }}:
8384
- name: _BuildArgs
84-
value: ''
85+
value: '/p:SkipTestBuild=true'
8586
- name: _SignType
8687
value: test
8788
- name: _PublishArgs

Directory.Build.props

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,42 @@
3636
<!-- Workaround issue with ComponentsAnalyzer throwing for interfaces -->
3737
<DisableImplicitComponentsAnalyzers>true</DisableImplicitComponentsAnalyzers>
3838
</PropertyGroup>
39+
40+
<!-- Disable logging of some task parameters or metadata to reduce binlog size.
41+
Reenable logging of any particular item by changing the value of the property below to 'false'
42+
The format is as follows:
43+
DisableLogTaskParameter_[task name]_[parameter name] - Disable logging of a particular parameter
44+
DisableLogTaskParameterItemMetadata_[task name]_[parameter name] - Disable logging of item metadata of the parameter
45+
-->
46+
<PropertyGroup>
47+
<TrimTaskParameters Condition=" '$(TrimTaskParameters)' == '' ">true</TrimTaskParameters>
48+
<!-- ItemsToHash is used for incremental building and hashes input properties to a file
49+
This is not generally useful for day-to-day build debugging. -->
50+
<DisableLogTaskParameter_Hash_ItemsToHash>$(TrimTaskParameters)</DisableLogTaskParameter_Hash_ItemsToHash>
51+
52+
<!-- JoinItems takes input ItemGroups. The output ItemGroup is logged. -->
53+
<DisableLogTaskParameter_JoinItems_Right>$(TrimTaskParameters)</DisableLogTaskParameter_JoinItems_Right>
54+
<DisableLogTaskParameter_JoinItems_Left>$(TrimTaskParameters)</DisableLogTaskParameter_JoinItems_Left>
55+
56+
<!-- ConvertToAbsolutePaths - The output parameter (AbsolutePaths) is interesting
57+
while the input Path is not generally useful. The output itemgroup's metadata
58+
is not altered by the task. -->
59+
<DisableLogTaskParameter_ConvertToAbsolutePath_Paths>$(TrimTaskParameters)</DisableLogTaskParameter_ConvertToAbsolutePath_Paths>
60+
<DisableLogTaskParameterItemMetadata_ConvertToAbsolutePath_Paths>$(TrimTaskParameters)</DisableLogTaskParameterItemMetadata_ConvertToAbsolutePath_Paths>
61+
62+
<!-- The standard msbuild Copy task does not use Metadata and thus the input/outputs
63+
item metadata is not relevant -->
64+
<DisableLogTaskParameterItemMetadata_Copy_SourceFiles>$(TrimTaskParameters)</DisableLogTaskParameterItemMetadata_Copy_SourceFiles>
65+
<DisableLogTaskParameterItemMetadata_Copy_DestinationFiles>$(TrimTaskParameters)</DisableLogTaskParameterItemMetadata_Copy_DestinationFiles>
66+
67+
<!-- Reference metadata for GenerateDepsFile, Csc, RAR, etc. are sometimes useful, but extraordinarily large
68+
when building against a shared framework where the number of input assemblies is very large.
69+
Avoid logging these by default. -->
70+
<DisableLogTaskParameterItemMetadata_GenerateDepsFile_ReferenceAssemblies>$(TrimTaskParameters)</DisableLogTaskParameterItemMetadata_GenerateDepsFile_ReferenceAssemblies>
71+
<DisableLogTaskParameterItemMetadata_GenerateDepsFile_ReferencePaths>$(TrimTaskParameters)</DisableLogTaskParameterItemMetadata_GenerateDepsFile_ReferencePaths>
72+
<DisableLogTaskParameterItemMetadata_ResolveAssemblyReference_Assemblies>$(TrimTaskParameters)</DisableLogTaskParameterItemMetadata_ResolveAssemblyReference_Assemblies>
73+
<DisableLogTaskParameterItemMetadata_Csc_References>$(TrimTaskParameters)</DisableLogTaskParameterItemMetadata_Csc_References>
74+
</PropertyGroup>
3975

4076
<Import Project="eng\QuarantinedTests.BeforeArcade.props" />
4177
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />

Directory.Build.targets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
<!-- Analyzer package are needed in source build for WebSDK -->
66
<ExcludeFromSourceBuild
77
Condition="'$(ExcludeFromSourceBuild)' == '' and '$(DotNetBuildFromSource)' == 'true' and '$(IsAspNetCoreApp)' != 'true' and '$(IsReferenceAssemblyProject)' != 'true' and '$(IsAnalyzersProject)' != 'true'">true</ExcludeFromSourceBuild>
8+
9+
<!-- If the user has specified that they want to skip building any test related projects with SkipTestBuild,
10+
suppress all targets for TestProjects using ExcludeFromBuild. -->
11+
<ExcludeFromBuild Condition="'$(SkipTestBuild)' == 'true' and
12+
('$(IsTestProject)' == 'true' or
13+
'$(IsUnitTestProject)' == 'true' or
14+
'$(IsTestAssetProject)' == 'true' or
15+
'$(IsBenchmarkProject)' == 'true' or
16+
'$(IsSampleProject)' == 'true' or
17+
'$(IsSpecificationTestProject)' == 'true')">true</ExcludeFromBuild>
818
</PropertyGroup>
919

1020
<PropertyGroup Label="Resx settings">

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/WebAssembly/Build/src/ReferenceBlazorBuildFromSource.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<_BlazorToolsDir>$(MSBuildThisFileDirectory)bin\$(BlazorBuildConfiguration)\tools\</_BlazorToolsDir>
1818
</PropertyGroup>
1919

20-
<Target Name="Check_BlazorJSFiles" BeforeTargets="Build">
20+
<Target Name="Check_BlazorJSFiles" BeforeTargets="Build" Condition="'$(ExcludeFromBuild)' != 'true'">
2121
<Error Text="blazor.webassembly.js file could not be found at $(_BlazorJsPath)" Condition="!Exists($(_BlazorJsPath))" />
2222
</Target>
2323

src/Servers/IIS/IIS/test/FunctionalTest.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Content Include="..\Common.FunctionalTests\AppHostConfig\*.config" CopyToOutputDirectory="PreserveNewest" />
99
</ItemGroup>
1010

11-
<Target Name="BuildAssets" AfterTargets="Build">
11+
<Target Name="BuildAssets" AfterTargets="Build" Condition="'$(ExcludeFromBuild)' != 'true'">
1212
<MSBuild Projects="@(ProjectReference)" Targets="PublishTestsAssets" SkipNonexistentTargets="true" BuildInParallel="True">
1313
<Output TaskParameter="TargetOutputs" ItemName="PublishedTestAsset" />
1414
</MSBuild>

src/Servers/IIS/IntegrationTesting.IIS/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<EmbeddedResource Include="Http.config" />
3030
</ItemGroup>
3131

32-
<Target Name="ValidateNativeComponentsBuilt" AfterTargets="Build" Condition="'$(BuildIisNativeProjects)' == 'true'">
32+
<Target Name="ValidateNativeComponentsBuilt" AfterTargets="Build" Condition="'$(BuildIisNativeProjects)' == 'true' and '$(SkipTestBuild)' != 'true'">
3333
<Error Text="Required dll from ANCM has not been built. To build ANCM, you must use MSBuild.exe."
3434
Condition="!Exists('$(AspNetCoreModuleV2ShimDll)') OR !Exists('$(AspNetCoreModuleV2OutOfProcessHandlerDll)')" />
3535
</Target>

src/SignalR/clients/java/signalr/signalr.client.java.Tests.javaproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
4343

4444
<!-- Define Target overrides after importing Directory.Build.targets so these don't get overridden -->
45-
<Target Name="Pack" DependsOnTargets="$(PackDependsOn)" Condition="'$(IsPackable)' == 'true'">
45+
<Target Name="Pack" DependsOnTargets="$(PackDependsOn)" Condition="'$(IsPackable)' == 'true' and '$(SkipTestBuild)' != 'true'">
4646
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Pack" />
4747
<Message Text="> gradlew $(GradleOptions) createPackage" Importance="high" />
4848
<Exec Command="./gradlew $(GradleOptions) createPackage" />
4949
<Message Importance="high" Text="java:signalr -> $(PackageOutputPath)%(JavaBuildFiles.Identity)" />
5050
<Copy SourceFiles="build\libs\%(JavaBuildFiles.Identity)" DestinationFolder="$(PackageOutputPath)" />
5151
</Target>
5252

53-
<Target Name="Build">
53+
<Target Name="Build" Condition="'$(SkipTestBuild)' != 'true'">
5454
<Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Build" />
5555
<Exec Command="./gradlew $(GradleOptions) compileJava" />
5656
</Target>

src/Tools/Microsoft.dotnet-openapi/test/dotnet-microsoft.openapi.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
<RemoveDir Directories="$(TargetDir)TestProjects" Condition="Exists('$(TargetDir)TestProjects')" />
4141
</Target>
4242

43-
<Target Name="PublishDotNetOpenApiOnBuild" BeforeTargets="Build" Condition="'$(DotNetBuildFromSource)' != 'true'">
43+
<Target Name="PublishDotNetOpenApiOnBuild" BeforeTargets="Build" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(ExcludeFromBuild)' != 'true'">
4444
<MSBuild Projects="$(OpenAPIToolCSProjPath)" Targets="Publish" Properties="PublishDir=$(OutputPath)\tool\;Configuration=$(Configuration)" />
4545
</Target>
4646

47-
<Target Name="PublishDotNetOpenApiOnPublish" BeforeTargets="Publish" Condition="'$(DotNetBuildFromSource)' != 'true'">
47+
<Target Name="PublishDotNetOpenApiOnPublish" BeforeTargets="Publish" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(ExcludeFromBuild)' != 'true'">
4848
<MSBuild Projects="$(OpenAPIToolCSProjPath)" Targets="Publish" Properties="PublishDir=$(PublishDir)\tool\;Configuration=$(Configuration)" />
4949
</Target>
5050
</Project>

src/Tools/dotnet-watch/test/dotnet-watch.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
</Target>
2929

3030
<!-- Do not publish in source build -->
31-
<Target Name="PublishDotNetWatchOnBuild" BeforeTargets="Build" Condition="'$(DotNetBuildFromSource)' != 'true'">
31+
<Target Name="PublishDotNetWatchOnBuild" BeforeTargets="Build" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(ExcludeFromBuild)' != 'true'">
3232
<MSBuild Projects="..\src\dotnet-watch.csproj"
3333
Targets="Publish"
3434
Properties="PublishDir=$(OutputPath)\tool\;Configuration=$(Configuration)" />
3535
</Target>
3636

3737
<!-- Do not publish in source build -->
38-
<Target Name="PublishDotNetWatchOnPublish" BeforeTargets="Publish" Condition="'$(DotNetBuildFromSource)' != 'true'">
38+
<Target Name="PublishDotNetWatchOnPublish" BeforeTargets="Publish" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(ExcludeFromBuild)' != 'true'">
3939
<MSBuild Projects="..\src\dotnet-watch.csproj"
4040
Targets="Publish"
4141
Properties="PublishDir=$(PublishDir)\tool\;Configuration=$(Configuration)" />

0 commit comments

Comments
 (0)