From 618bf0f7dddd2275bbfd55bf8b499218a63447d7 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Tue, 9 Dec 2025 12:56:55 -0600 Subject: [PATCH 1/3] Fix wbt AppsettingsTests --- eng/testing/scenarios/BuildWasmAppsJobsList.txt | 1 + .../Wasm.Build.Tests/Blazor/AppsettingsTests.cs | 1 - .../Blazor/BlazorWasmTestBase.cs | 2 +- .../Templates/WasmTemplateTestsBase.cs | 17 ++++++----------- .../WasmSdkBasedProjectProvider.cs | 2 ++ 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/eng/testing/scenarios/BuildWasmAppsJobsList.txt b/eng/testing/scenarios/BuildWasmAppsJobsList.txt index 312c79d785d3b2..1d4e72cb0486f9 100644 --- a/eng/testing/scenarios/BuildWasmAppsJobsList.txt +++ b/eng/testing/scenarios/BuildWasmAppsJobsList.txt @@ -5,6 +5,7 @@ Wasm.Build.NativeRebuild.Tests.ReferenceNewAssemblyRebuildTest Wasm.Build.NativeRebuild.Tests.SimpleSourceChangeRebuildTest Wasm.Build.Tests.InterpPgoTests Wasm.Build.Templates.Tests.NativeBuildTests +Wasm.Build.Tests.Blazor.AppsettingsTests Wasm.Build.Tests.Blazor.BuildPublishTests Wasm.Build.Tests.Blazor.SimpleRunTests Wasm.Build.Tests.Blazor.CleanTests diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/AppsettingsTests.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/AppsettingsTests.cs index b1f5bd28f6d3bd..6eea340f1d2728 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/AppsettingsTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/AppsettingsTests.cs @@ -20,7 +20,6 @@ public AppsettingsTests(ITestOutputHelper output, SharedBuildPerTestClassFixture } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/122338")] // add it back to eng\testing\scenarios\BuildWasmAppsJobsList.txt public async Task FileInVfs() { Configuration config = Configuration.Debug; diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs index 1f4340260087d1..28bac8d2b8ba21 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs @@ -221,5 +221,5 @@ public override async Task RunForPublishWithWebServer(RunOptions runO } public string GetBlazorBinFrameworkDir(Configuration config, bool forPublish, string? framework = null, string? projectDir = null) - => _provider.GetBinFrameworkDir(config: config, forPublish: forPublish, framework: framework ?? DefaultTargetFrameworkForBlazor, projectDir: projectDir); + => _provider.GetBinFrameworkDir(config: config, forPublish: forPublish, framework: framework ?? _provider.GetDefaultTargetFramework(), projectDir: projectDir); } diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs index 042c107a1a923c..3d86a619ed869f 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs @@ -73,14 +73,9 @@ public ProjectInfo CreateWasmTemplateProject( (string projectName, string logPath, string nugetDir) = InitProjectLocation(idPrefix, config, aot, appendUnicodeToPath ?? s_buildEnv.IsRunningOnCI); - if (addFrameworkArg) { - var defaultTarget = template switch - { - Template.BlazorWasm => DefaultTargetFrameworkForBlazorTemplate, - _ => DefaultTargetFramework, - }; - - extraArgs += $" -f {defaultTarget}"; + if (addFrameworkArg) + { + extraArgs += $" -f {_provider.GetDefaultTargetFramework()}"; } using DotNetCommand cmd = new DotNetCommand(s_buildEnv, _testOutput, useDefaultArgs: false); @@ -282,7 +277,7 @@ protected void DeleteFile(string pathRelativeToProjectDir) protected void UpdateBrowserMainJs(string? targetFramework = null, string runtimeAssetsRelativePath = DefaultRuntimeAssetsRelativePath) { - targetFramework ??= DefaultTargetFramework; + targetFramework ??= _provider.GetDefaultTargetFramework(); string mainJsPath = Path.Combine(_projectDir, "wwwroot", "main.js"); string mainJsContent = File.ReadAllText(mainJsPath); Version targetFrameworkVersion = new Version(targetFramework.Replace("net", "")); @@ -431,10 +426,10 @@ void OnErrorMessage(string msg) } public string GetBinFrameworkDir(Configuration config, bool forPublish, string? framework = null, string? projectDir = null) => - _provider.GetBinFrameworkDir(config, forPublish, framework ?? DefaultTargetFramework, projectDir); + _provider.GetBinFrameworkDir(config, forPublish, framework ?? _provider.GetDefaultTargetFramework(), projectDir); public string GetObjDir(Configuration config, string? framework = null, string? projectDir = null) => - _provider.GetObjDir(config, framework ?? DefaultTargetFramework, projectDir); + _provider.GetObjDir(config, framework ?? _provider.GetDefaultTargetFramework(), projectDir); public BuildPaths GetBuildPaths(Configuration config, bool forPublish) => _provider.GetBuildPaths(config, forPublish); diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs index afffefce4e82f7..89e6819768d387 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs @@ -24,6 +24,8 @@ public WasmSdkBasedProjectProvider(ITestOutputHelper _testOutput, string default protected override string BundleDirName { get { return "wwwroot"; } } + public string GetDefaultTargetFramework() => _defaultTargetFramework; + protected override IReadOnlyDictionary GetAllKnownDotnetFilesToFingerprintMap(AssertBundleOptions assertOptions) { var result = new SortedDictionary() From 93eb607a63e098d353a14f9a86509329ef5b17aa Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Tue, 9 Dec 2025 16:14:01 -0600 Subject: [PATCH 2/3] Work around the failure here --- .../wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs index 89e6819768d387..adeb41abbbda8b 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs @@ -180,10 +180,13 @@ private void AssertBundle(AssertBundleOptions assertOptions) public void AssertWasmSdkBundle(Configuration config, MSBuildOptions buildOptions, bool isUsingWorkloads, bool? isNativeBuild = null, bool? wasmFingerprintDotnetJs = null, string? buildOutput = null) { - if (isUsingWorkloads && buildOutput is not null) + if ((isUsingWorkloads && buildOutput is not null) + && (_defaultTargetFramework == BuildTestBase.DefaultTargetFramework)) { // In no-workload case, the path would be from a restored nuget - ProjectProviderBase.AssertRuntimePackPath(buildOutput, buildOptions.TargetFramework ?? _defaultTargetFramework, buildOptions.RuntimeType); + // FIXME: if the _defaultTargetFramework is not the same as the the DefaultTargetFramework + // we skup the RuntimePath check as the path would be from a restored nuget + AssertRuntimePackPath(buildOutput, buildOptions.TargetFramework ?? _defaultTargetFramework, buildOptions.RuntimeType); } AssertBundle(config, buildOptions, isUsingWorkloads, isNativeBuild, wasmFingerprintDotnetJs); } From 20d56b566f1eff89a5512fa97a02bccad5ffda73 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Wed, 10 Dec 2025 21:13:22 -0600 Subject: [PATCH 3/3] Stir the pot --- .../Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs | 4 ++-- .../Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs index 28bac8d2b8ba21..04a018a4619c71 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs @@ -27,8 +27,8 @@ protected BlazorWasmTestBase(ITestOutputHelper output, SharedBuildPerTestClassFi : base(output, buildContext, new WasmSdkBasedProjectProvider(output, targetFramework ?? DefaultTargetFrameworkForBlazor)) { _provider = GetProvider(); - _defaultBlazorPublishOptions = _defaultPublishOptions with { ExtraMSBuildArgs = _blazorExtraMSBuildArgs }; - _defaultBlazorBuildOptions = _defaultBuildOptions with { ExtraMSBuildArgs = _blazorExtraMSBuildArgs }; + _defaultBlazorPublishOptions = _defaultPublishOptions with { ExtraMSBuildArgs = _blazorExtraMSBuildArgs, TargetFramework = targetFramework ?? DefaultTargetFrameworkForBlazor }; + _defaultBlazorBuildOptions = _defaultBuildOptions with { ExtraMSBuildArgs = _blazorExtraMSBuildArgs, TargetFramework = targetFramework ?? DefaultTargetFrameworkForBlazor }; } private Dictionary blazorHomePageReplacements = new Dictionary diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs index adeb41abbbda8b..4af3e6280409a2 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs @@ -129,7 +129,7 @@ private void AssertBundle(AssertBundleOptions assertOptions) Assert.False(wasmAssemblies.Any(), $"Did not expect to find any .wasm files in {publishPath} but found {string.Join(",", wasmAssemblies)}"); } - if (!BuildTestBase.IsUsingWorkloads) + if (!BuildTestBase.IsUsingWorkloads || assertOptions.BuildOptions.TargetFramework != BuildTestBase.DefaultTargetFramework) return; // Compare files with the runtime pack @@ -180,13 +180,11 @@ private void AssertBundle(AssertBundleOptions assertOptions) public void AssertWasmSdkBundle(Configuration config, MSBuildOptions buildOptions, bool isUsingWorkloads, bool? isNativeBuild = null, bool? wasmFingerprintDotnetJs = null, string? buildOutput = null) { - if ((isUsingWorkloads && buildOutput is not null) - && (_defaultTargetFramework == BuildTestBase.DefaultTargetFramework)) + string targetFramework = buildOptions.TargetFramework ?? _defaultTargetFramework; + + if (isUsingWorkloads && buildOutput is not null && targetFramework == BuildTestBase.DefaultTargetFramework) { - // In no-workload case, the path would be from a restored nuget - // FIXME: if the _defaultTargetFramework is not the same as the the DefaultTargetFramework - // we skup the RuntimePath check as the path would be from a restored nuget - AssertRuntimePackPath(buildOutput, buildOptions.TargetFramework ?? _defaultTargetFramework, buildOptions.RuntimeType); + AssertRuntimePackPath(buildOutput, targetFramework, buildOptions.RuntimeType); } AssertBundle(config, buildOptions, isUsingWorkloads, isNativeBuild, wasmFingerprintDotnetJs); }