From 95e2793bde7aff936b63db4b91be5709bf1ffaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Mon, 9 Mar 2026 12:55:43 +0000 Subject: [PATCH 1/3] Add MSBuild incrementalism to WASM boot JSON generation targets Split _GenerateBuildWasmBootJson and GeneratePublishWasmBootJson into smaller targets to enable Inputs/Outputs-based incrementalism for the expensive GenerateWasmBootJson task invocations. Build path split: - _ResolveBuildWasmBootJsonEndpoints: always runs, resolves endpoints - _WriteBuildWasmBootJsonFile: incremental (Inputs/Outputs), writes boot JSON - _GenerateBuildWasmBootJson: always runs, defines boot config as static web asset Publish path split: - _ResolvePublishWasmBootJsonInputs: always runs, resolves publish inputs - GeneratePublishWasmBootJson: incremental (Inputs/Outputs), writes boot JSON When no inputs have changed, the GenerateWasmBootJson task (~100ms) is skipped entirely. The always-running targets handle endpoint resolution and asset definition to ensure downstream item collections remain populated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...rosoft.NET.Sdk.WebAssembly.Browser.targets | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets index 30970d18aa4eb9..54647b56d47027 100644 --- a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets +++ b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets @@ -429,7 +429,9 @@ Copyright (c) .NET Foundation. All rights reserved. - + + <_WasmBuildBootJsonPath>$(IntermediateOutputPath)$(_WasmBootConfigFileName) <_WasmBuildApplicationEnvironmentName>$(WasmApplicationEnvironmentName) @@ -483,6 +485,15 @@ Copyright (c) .NET Foundation. All rights reserved. > + + + + + + + + <_WasmBuildBootConfigCandidate @@ -873,7 +889,8 @@ Copyright (c) .NET Foundation. All rights reserved. - + + <_WasmPublishApplicationEnvironmentName>$(WasmApplicationEnvironmentName) @@ -906,6 +923,14 @@ Copyright (c) .NET Foundation. All rights reserved. > + + + + Date: Mon, 9 Mar 2026 13:45:27 +0000 Subject: [PATCH 2/3] Add MSBuild incrementalism to webcil conversion target Split the monolithic _ResolveWasmOutputs target into three targets to enable MSBuild Inputs/Outputs-based skip optimization for DLL-to-webcil conversion: - _ComputeWasmBuildCandidates (always runs): resolves build asset candidates via ComputeWasmBuildAssets, separates DLL candidates into culture/non-culture groups, and computes expected webcil output paths. - _ConvertBuildDllsToWebcil (incremental): runs ConvertDllsToWebcil only when input DLLs are newer than their webcil outputs. The task also retains its internal per-file timestamp checks as a secondary optimization. - _ResolveWasmOutputs (always runs): reconstructs webcil candidate items from build asset candidates using MSBuild item transforms (matching the ConvertDllsToWebcil task's path/metadata logic), then calls DefineStaticWebAssets to produce the final asset definitions. Culture and non-culture DLLs are separated into distinct intermediate items (_WasmWebcilConvertedNonCulture / _WasmWebcilConvertedCulture) to avoid MSBuild batching errors on metadata like RelatedAsset that only culture items define. The _ResolveWasmOutputs target lists _ComputeWasmBuildCandidates explicitly in its DependsOnTargets (before _ConvertBuildDllsToWebcil) to ensure _WasmEnableWebcil is set by _ResolveWasmConfiguration before the conversion target's Condition is evaluated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...rosoft.NET.Sdk.WebAssembly.Browser.targets | 67 ++++++++++++++++++- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets index 54647b56d47027..b9d69ac19f52e6 100644 --- a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets +++ b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets @@ -291,7 +291,9 @@ Copyright (c) .NET Foundation. All rights reserved. - + + <_WasmNativeAssetFileNames>;@(WasmNativeAsset->'%(FileName)%(Extension)');@(WasmAssembliesFinal->'%(FileName)%(Extension)'); <_WasmIntermediateAssemblyFileNames Condition="@(WasmAssembliesFinal->Count()) != 0">;@(IntermediateAssembly->'%(FileName)%(Extension)'); @@ -355,10 +357,69 @@ Copyright (c) .NET Foundation. All rights reserved. <_WasmBuildTmpWebcilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'tmp-webcil')) - - + + + <_WasmDllBuildCandidates Include="@(_BuildAssetsCandidates)" Condition="'%(Extension)' == '.dll'" /> + <_WasmDllBuildCandidatesNonCulture Include="@(_WasmDllBuildCandidates)" Condition="'%(AssetTraitName)' != 'Culture'" /> + <_WasmDllBuildCandidatesCulture Include="@(_WasmDllBuildCandidates)" Condition="'%(AssetTraitName)' == 'Culture'" /> + <_WasmExpectedWebcilOutputs Include="@(_WasmDllBuildCandidatesNonCulture->'$(_WasmBuildWebcilPath)%(FileName).wasm')" /> + <_WasmExpectedWebcilOutputs Include="@(_WasmDllBuildCandidatesCulture->'$(_WasmBuildWebcilPath)%(AssetTraitValue)/%(FileName).wasm')" /> + + + + + + + + + + + + + + + <_WasmWebcilConvertedNonCulture Include="@(_WasmDllBuildCandidatesNonCulture->'$(_WasmBuildWebcilPath)%(FileName).wasm')"> + $([System.IO.Path]::ChangeExtension(%(RelativePath), '.wasm')) + $(_WasmBuildWebcilPath)%(FileName).wasm + + <_WasmWebcilConvertedCulture Include="@(_WasmDllBuildCandidatesCulture->'$(_WasmBuildWebcilPath)%(AssetTraitValue)/%(FileName).wasm')"> + $([System.IO.Path]::ChangeExtension(%(RelativePath), '.wasm')) + $(_WasmBuildWebcilPath)%(AssetTraitValue)/%(FileName).wasm + $([System.IO.Path]::ChangeExtension(%(RelatedAsset), '.wasm')) + + + + <_WebcilAssetsCandidates Include="@(_BuildAssetsCandidates)" Condition="'%(Extension)' != '.dll'" /> + <_WebcilAssetsCandidates Include="@(_WasmWebcilConvertedNonCulture)" /> + <_WebcilAssetsCandidates Include="@(_WasmWebcilConvertedCulture)" /> + + + + + + + + <_WebcilAssetsCandidates Include="@(_BuildAssetsCandidates)" /> + From 7b87b01d4112da793ce3021600943f67adffcb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 10 Mar 2026 12:09:50 +0000 Subject: [PATCH 3/3] Feedback --- .../build/Microsoft.NET.Sdk.WebAssembly.Browser.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets index b9d69ac19f52e6..485860bf2f68ae 100644 --- a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets +++ b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets @@ -990,7 +990,7 @@ Copyright (c) .NET Foundation. All rights reserved. inputs are older than the output. -->