From bcd62ed9e32e01a190563750182e627d762da7c5 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 20 Dec 2022 10:00:46 -0600 Subject: [PATCH] [build] pack .NET `.nupkg` files in parallel Previously, we were calling `dotnet pack` serially for many projects, such as: This ends up taking a while: Target CreateAllPacks 52.127s Task Exec 3.712s Task Exec 3.569s Task Exec 3.432s Task Exec 3.434s Task Exec 24.741s Task Exec 7.257s Task Exec 2.507s Task Exec 3.468s Instead, we can create a `@(_ProjectsToPack)` item group, set `%(AdditionalProperties)`, and call the `` task: This is faster because: * We don't shell out to a new `dotnet.exe` each time. * `` task knows how to run in parallel, managing multiple MSBuild nodes. This also has the benefit of including these `dotnet pack` commands in the `.binlog`. Previously, we would just have console output for them. After these changes, I instead see: Target CreateAllPacks 5.857s Task MSBuild 5.857s From my numbers before, I am unsure why one of the `dotnet pack` commands took ~24 seconds. But I believe this change should reduce the time to the *slowest` individual `dotnet pack` now. It could save up to ~1 min of time in the `CreateAllPacks` target. --- .../create-packs/Directory.Build.targets | 50 ++++++++++++------- .../Microsoft.Android.Templates.csproj | 2 +- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/build-tools/create-packs/Directory.Build.targets b/build-tools/create-packs/Directory.Build.targets index 8cb06e245c0..4ecda2455d9 100644 --- a/build-tools/create-packs/Directory.Build.targets +++ b/build-tools/create-packs/Directory.Build.targets @@ -46,9 +46,9 @@ - <_GlobalProperties Include="-p:Configuration=$(Configuration)" /> - <_GlobalProperties Include="-p:NuGetLicense=$(NuGetLicense)" /> - <_GlobalProperties Include="-p:IncludeSymbols=False" /> + <_GlobalProperties Include="Configuration=$(Configuration)" /> + <_GlobalProperties Include="NuGetLicense=$(NuGetLicense)" /> + <_GlobalProperties Include="IncludeSymbols=False" /> @@ -58,30 +58,42 @@ - + + <_ProjectsToPack Include="Microsoft.Android.Ref.proj" AdditionalProperties="AndroidApiLevel=$(AndroidDefaultTargetDotnetApiLevel)" /> + - - - - - + + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidApiLevel=$(AndroidLatestUnstableApiLevel);AndroidRID=android-arm" /> + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidApiLevel=$(AndroidLatestUnstableApiLevel);AndroidRID=android-arm64" /> + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidApiLevel=$(AndroidLatestUnstableApiLevel);AndroidRID=android-x86" /> + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidApiLevel=$(AndroidLatestUnstableApiLevel);AndroidRID=android-x64" /> + <_ProjectsToPack Include="Microsoft.Android.Ref.proj" AdditionalProperties="AndroidApiLevel=$(AndroidLatestUnstableApiLevel)" /> + - - - - - - - - - - + + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidRID=android-arm" /> + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidRID=android-arm64" /> + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidRID=android-x86" /> + <_ProjectsToPack Include="Microsoft.Android.Runtime.proj" AdditionalProperties="AndroidRID=android-x64" /> + <_ProjectsToPack Include="Microsoft.Android.Ref.proj" /> + <_ProjectsToPack Include="Microsoft.Android.Sdk.proj" AdditionalProperties="HostOS=Linux" Condition=" '$(HostOS)' == 'Linux' " /> + <_ProjectsToPack Include="Microsoft.Android.Sdk.proj" AdditionalProperties="HostOS=Darwin" Condition=" '$(HostOS)' == 'Darwin' " /> + <_ProjectsToPack Include="Microsoft.Android.Sdk.proj" AdditionalProperties="HostOS=Windows" Condition=" '$(HostOS)' != 'Linux' " /> + <_ProjectsToPack Include="Microsoft.NET.Sdk.Android.proj" /> + <_ProjectsToPack Include="$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\Microsoft.Android.Templates.csproj" /> + + + netstandard2.0