From 5045603b4821df2700beb675fa0cee2eeb96dc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 14:35:33 +0100 Subject: [PATCH 1/6] Library mode without workload --- src/mono/browser/build/BrowserWasmApp.targets | 9 -------- ...rosoft.NET.Sdk.WebAssembly.Browser.targets | 9 ++++++++ .../Templates/WasmTemplateTests.cs | 21 +++++++++++++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/mono/browser/build/BrowserWasmApp.targets b/src/mono/browser/build/BrowserWasmApp.targets index 9f71350badd04a..91b0db7e78fac6 100644 --- a/src/mono/browser/build/BrowserWasmApp.targets +++ b/src/mono/browser/build/BrowserWasmApp.targets @@ -49,15 +49,6 @@ - - - - - all - - - - 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 bad785110dabbf..58e11699f21b96 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 @@ -927,4 +927,13 @@ Copyright (c) .NET Foundation. All rights reserved. Condition="Exists('$(_DotnetTypesSourcePath)')" SkipUnchangedFiles="true" /> + + + + + + all + + + diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs index b458e471c57230..68b9459d70995a 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs @@ -297,9 +297,11 @@ void AssertFile(string suffix) } [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task LibraryModeBuild(bool useWasmSdk) + [InlineData(false, false)] + [InlineData(true, false)] + [InlineData(false, true)] + [InlineData(true, true)] + public async Task LibraryMode(bool useWasmSdk, bool isPublish) { var config = Configuration.Release; ProjectInfo info = CopyTestAsset(config, aot: false, TestAsset.LibraryModeTestApp, "libraryMode"); @@ -309,13 +311,20 @@ public async Task LibraryModeBuild(bool useWasmSdk) { "Microsoft.NET.Sdk.WebAssembly", "Microsoft.NET.Sdk" } }); } - BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk)); + + if (isPublish) + PublishProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk)); + else + BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk)); + if (useWasmSdk) { - var result = await RunForBuildWithDotnetRun(new BrowserRunOptions(config, ExpectedExitCode: 100)); + var result = isPublish + ? await RunForPublishWithWebServer(new BrowserRunOptions(config, ExpectedExitCode: 100)); + : await RunForBuildWithDotnetRun(new BrowserRunOptions(config, ExpectedExitCode: 100)); + Assert.Contains("WASM Library MyExport is called", result.TestOutput); } - } [Theory] From b3709e43c46fd81fc35190f42af7be8aa2bff3ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 15:18:52 +0100 Subject: [PATCH 2/6] Fix --- src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs index 68b9459d70995a..7b239bd4c9b9df 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs @@ -320,7 +320,7 @@ public async Task LibraryMode(bool useWasmSdk, bool isPublish) if (useWasmSdk) { var result = isPublish - ? await RunForPublishWithWebServer(new BrowserRunOptions(config, ExpectedExitCode: 100)); + ? await RunForPublishWithWebServer(new BrowserRunOptions(config, ExpectedExitCode: 100)) : await RunForBuildWithDotnetRun(new BrowserRunOptions(config, ExpectedExitCode: 100)); Assert.Contains("WASM Library MyExport is called", result.TestOutput); From 991951b94b7f9f3f6ae76dcb6001859fd77392f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 17 Dec 2025 17:21:42 +0100 Subject: [PATCH 3/6] Fix --- src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs index 7b239bd4c9b9df..af1d2a92a9e2ee 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs @@ -313,7 +313,7 @@ public async Task LibraryMode(bool useWasmSdk, bool isPublish) } if (isPublish) - PublishProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk)); + PublishProject(info, config, new PublishOptions(AssertAppBundle: useWasmSdk)); else BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk)); From 5f80cfdf327e2270a2acd4d6b746bc6f0dfccb2e Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 20:50:33 +0100 Subject: [PATCH 4/6] Fix LibraryMode test to expect publish failure without WASM SDK (#122615) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description The `LibraryMode` test variant with `useWasmSdk: False, isPublish: True` is expected to fail, but the test was asserting success for all variants. Updated test to set `ExpectSuccess: false` when publishing without WASM SDK, verifying the operation exits with code 1 as expected. ```csharp // Publishing without WASM SDK is expected to fail bool expectSuccess = useWasmSdk || !isPublish; if (isPublish) PublishProject(info, config, new PublishOptions(AssertAppBundle: useWasmSdk, ExpectSuccess: expectSuccess)); else BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk, ExpectSuccess: expectSuccess)); ``` # Customer Impact No customer impact - test-only change. # Regression No. Test was incomplete, not validating the expected failure scenario. # Testing Test compiles successfully. The updated test will properly validate all four variants: - Build without SDK: succeeds - Build with SDK: succeeds - Publish with SDK: succeeds - Publish without SDK: **fails** (now correctly validated) # Risk Minimal - test-only change with no production code impact. --- ✨ Let Copilot coding agent [set things up for you](https://github.com/dotnet/runtime/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: maraf <10020471+maraf@users.noreply.github.com> --- .../wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs index af1d2a92a9e2ee..bde1cfdd09da7d 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs @@ -312,10 +312,12 @@ public async Task LibraryMode(bool useWasmSdk, bool isPublish) }); } + // Publishing without WASM SDK is expected to fail + bool expectSuccess = useWasmSdk || !isPublish; if (isPublish) - PublishProject(info, config, new PublishOptions(AssertAppBundle: useWasmSdk)); + PublishProject(info, config, new PublishOptions(AssertAppBundle: useWasmSdk, ExpectSuccess: expectSuccess)); else - BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk)); + BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk, ExpectSuccess: expectSuccess)); if (useWasmSdk) { From 5d9b5076f2de706f46a325c33f0f75cd0efba6ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 14:36:22 +0100 Subject: [PATCH 5/6] Move the test to no-workload --- src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs index bde1cfdd09da7d..7dced5b760bfdf 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs @@ -296,7 +296,7 @@ void AssertFile(string suffix) } } - [Theory] + [Theory, TestCategory("no-workload")] [InlineData(false, false)] [InlineData(true, false)] [InlineData(false, true)] From 99852869028a8af5a55bd12d277f6a961da05353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 18 Dec 2025 20:09:06 +0100 Subject: [PATCH 6/6] Empty _UsingBlazorOrWasmSdk shouldn't trigger requirement for workload --- .../WorkloadManifest.targets.in | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in index e5fb9c71177b93..30b3e1760648f4 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in @@ -64,7 +64,6 @@ '$(WasmProfilers)' != '' or '$(RunAOTCompilation)' == 'true' or '$(WasmBuildNative)' == 'true' or - '$(_UsingBlazorOrWasmSdk)' != 'true' or '$(EmccInitialHeapSize)' != '' or '$(EmccMaximumHeapSize)' != '' " >true