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 52d869fca3df6a..63554a5b72e5e7 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 @@ -292,7 +292,9 @@ Copyright (c) .NET Foundation. All rights reserved. - + + <_WasmNativeAssetFileNames>;@(WasmNativeAsset->'%(FileName)%(Extension)');@(WasmAssembliesFinal->'%(FileName)%(Extension)'); <_WasmIntermediateAssemblyFileNames Condition="@(WasmAssembliesFinal->Count()) != 0">;@(IntermediateAssembly->'%(FileName)%(Extension)'); @@ -362,17 +364,116 @@ Copyright (c) .NET Foundation. All rights reserved. <_WasmFrameworkCopyToOutputDirectory Condition="'$(_WasmFrameworkCopyToOutputDirectory)' == ''">Never - - - + + + + <_WasmDllBuildCandidates Include="@(_BuildAssetsCandidates)" Condition="'%(Extension)' == '.dll'" /> + <_WasmDllBuildCandidatesNonCulture Include="@(_WasmDllBuildCandidates)" Condition="'%(AssetTraitName)' != 'Culture'"> + $(_WasmBuildWebcilPath)%(FileName).wasm + + <_WasmDllBuildCandidatesCulture Include="@(_WasmDllBuildCandidates)" Condition="'%(AssetTraitName)' == 'Culture'"> + $(_WasmBuildWebcilPath)%(AssetTraitValue)/%(FileName).wasm + + + <_WasmDllBuildCandidates Remove="@(_WasmDllBuildCandidates)" /> + <_WasmDllBuildCandidates Include="@(_WasmDllBuildCandidatesNonCulture);@(_WasmDllBuildCandidatesCulture)" /> + <_WasmExpectedWebcilOutputs Include="@(_WasmDllBuildCandidates->'%(WebcilOutputPath)')" /> + + + + + <_WasmNativeBuildOutputCandidates Include="@(_BuildAssetsCandidates)" Condition="'%(Extension)' != '.dll' and '%(_BuildAssetsCandidates.WasmNativeBuildOutput)' != ''" /> + <_WasmNonDllNonNativeCandidates Include="@(_BuildAssetsCandidates)" Condition="'%(Extension)' != '.dll'" /> + <_WasmNonDllNonNativeCandidates Remove="@(_WasmNativeBuildOutputCandidates)" /> + + + + + + + + - - - <_WebcilAssetsCandidates Remove="@(_WasmFrameworkCandidates)" /> + + + + + + + + + + <_WasmWebcilConvertedNonCulture Include="@(_WasmDllBuildCandidatesNonCulture->'%(WebcilOutputPath)')"> + $([System.IO.Path]::ChangeExtension(%(RelativePath), '.wasm')) + %(WebcilOutputPath) + + <_WasmWebcilConvertedCulture Include="@(_WasmDllBuildCandidatesCulture->'%(WebcilOutputPath)')"> + $([System.IO.Path]::ChangeExtension(%(RelativePath), '.wasm')) + %(WebcilOutputPath) + $([System.IO.Path]::ChangeExtension(%(RelatedAsset), '.wasm')) + + + + <_WebcilAssetsCandidates Include="@(_WasmNativeBuildOutputCandidates)" /> + <_WebcilAssetsCandidates Include="@(_WasmWebcilConvertedNonCulture)" /> + <_WebcilAssetsCandidates Include="@(_WasmWebcilConvertedCulture)" /> + + + <_WasmFrameworkCandidates Include="@(_WasmNonDllNonNativeCandidates)" /> + + + + + + + + <_WebcilAssetsCandidates Include="@(_WasmNativeBuildOutputCandidates)" /> + <_WasmFrameworkCandidates Include="@(_WasmNonDllNonNativeCandidates)" /> + <_WasmFrameworkCandidates Include="@(_BuildAssetsCandidates)" Condition="'%(Extension)' == '.dll'" /> @@ -489,7 +590,9 @@ Copyright (c) .NET Foundation. All rights reserved. - + + <_WasmBuildBootJsonPath>$(IntermediateOutputPath)$(_WasmBootConfigFileName) <_WasmBuildApplicationEnvironmentName>$(WasmApplicationEnvironmentName) @@ -543,6 +646,33 @@ Copyright (c) .NET Foundation. All rights reserved. > + + + + + + <_WasmBootJsonBuildStampContent>$(WasmDebugLevel)|$(_WasmBuildApplicationEnvironmentName)|$(_BlazorCacheBootResources)|$(InvariantGlobalization)|$(_LoadCustomIcuData)|$(_BlazorWebAssemblyLoadAllGlobalizationData)|$(_BlazorWebAssemblyJiterpreter)|$(_BlazorWebAssemblyRuntimeOptions)|$(RunAOTCompilation)|$(WasmEnableThreads)|$(_WasmFingerprintAssets)|$(_WasmBundlerFriendlyBootConfig)|$(WasmProfilers)|$(TargetFrameworkVersion)|$(DiagnosticPorts)|$(StaticWebAssetStandaloneHosting)|@(WasmEnvironmentVariable->'%(Identity)=%(Value)')|@(BlazorWebAssemblyLazyLoad)|@(WasmModuleAfterConfigLoaded)|@(WasmModuleAfterRuntimeReady)|$(WasmTestExitOnUnhandledError)|$(WasmTestAppendElementOnExit)|$(WasmTestLogExitCode)|$(WasmTestAsyncFlushOnExit)|$(WasmTestForwardConsole) + + + + + + + + + + + + + + + + + + <_WasmBuildBootConfigCandidate Include="$(_WasmBuildBootJsonPath)" RelativePath="_framework/$(_WasmBootConfigFileName)" /> @@ -902,6 +1044,8 @@ Copyright (c) .NET Foundation. All rights reserved. + + <_WasmPublishBootConfigCandidate Include="$(IntermediateOutputPath)$(_WasmPublishBootConfigFileName)" RelativePath="_framework/$(_WasmBootConfigFileName)" /> @@ -939,7 +1083,9 @@ Copyright (c) .NET Foundation. All rights reserved. - + + <_WasmPublishApplicationEnvironmentName>$(WasmApplicationEnvironmentName) @@ -972,6 +1118,31 @@ Copyright (c) .NET Foundation. All rights reserved. > + + + + + + <_WasmBootJsonPublishStampContent>$(WasmDebugLevel)|$(_WasmPublishApplicationEnvironmentName)|$(_BlazorCacheBootResources)|$(InvariantGlobalization)|$(_LoadCustomIcuData)|$(_BlazorWebAssemblyLoadAllGlobalizationData)|$(_BlazorWebAssemblyJiterpreter)|$(_BlazorWebAssemblyRuntimeOptions)|$(RunAOTCompilation)|$(WasmEnableThreads)|$(_WasmFingerprintAssets)|$(_WasmBundlerFriendlyBootConfig)|$(WasmProfilers)|$(TargetFrameworkVersion)|$(DiagnosticPorts)|$(StaticWebAssetStandaloneHosting)|@(WasmEnvironmentVariable->'%(Identity)=%(Value)')|@(BlazorWebAssemblyLazyLoad)|@(WasmModuleAfterConfigLoaded)|@(WasmModuleAfterRuntimeReady)|$(WasmTestExitOnUnhandledError)|$(WasmTestAppendElementOnExit)|$(WasmTestLogExitCode)|$(WasmTestAsyncFlushOnExit)|$(WasmTestForwardConsole) + + + + + + + + + + + + f.Contains(info.ProjectName, StringComparison.OrdinalIgnoreCase)); + } + } + + private static void AssertTargetSkipped(string binlogPath, string targetName) + { + var build = SL.BinaryLog.ReadBuild(binlogPath); + SL.BuildAnalyzer.AnalyzeBuild(build); + + bool found = false; + bool skipped = false; + build.VisitAllChildren(t => + { + if (t.Name == targetName) + { + found = true; + if (t.Children.OfType().Any(m => + m.Text is not null && m.Text.Contains("Skipping target"))) + { + skipped = true; + } + } + }); + + Assert.True(found, $"Target '{targetName}' was not found in the binlog '{binlogPath}'."); + Assert.True(skipped, $"Target '{targetName}' was expected to be skipped but it ran."); + } + + private static void AssertTargetRan(string binlogPath, string targetName) + { + var build = SL.BinaryLog.ReadBuild(binlogPath); + SL.BuildAnalyzer.AnalyzeBuild(build); + + bool found = false; + bool ran = false; + build.VisitAllChildren(t => + { + if (t.Name == targetName) + { + found = true; + if (t.Children.OfType().Any(m => + m.Text is not null && m.Text.Contains("Building target"))) + { + ran = true; + } + } + }); + + Assert.True(found, $"Target '{targetName}' was not found in the binlog '{binlogPath}'."); + Assert.True(ran, $"Target '{targetName}' was expected to run but it was skipped."); + } + + private static List GetConvertedWebcilFiles(string binlogPath) + { + var build = SL.BinaryLog.ReadBuild(binlogPath); + SL.BuildAnalyzer.AnalyzeBuild(build); + + var converted = new List(); + build.VisitAllChildren(t => + { + if (t.Name != "_ConvertBuildDllsToWebcil") + return; + + foreach (var child in t.Children) + { + if (child is not SL.Task { Name: "ConvertDllsToWebcil" } convertTask) + continue; + + convertTask.VisitAllChildren(m => + { + if (m.Text is not null && m.Text.StartsWith("Converting to Webcil:")) + converted.Add(m.Text); + }); + } + }); + + return converted; + } } }