diff --git a/src/mono/browser/build/BrowserWasmApp.targets b/src/mono/browser/build/BrowserWasmApp.targets index 9c2e43f2696b99..ea0b33bb83ebeb 100644 --- a/src/mono/browser/build/BrowserWasmApp.targets +++ b/src/mono/browser/build/BrowserWasmApp.targets @@ -50,15 +50,6 @@ - - - - - all - - - - diff --git a/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.props b/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.props index 5cf994ce01a91d..2f426e26a69153 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.props @@ -3,6 +3,5 @@ wasm browser Exe - true 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 6442c23e87d1ac..75bfecf4f788da 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 @@ -1069,4 +1069,13 @@ Copyright (c) .NET Foundation. All rights reserved. Condition="Exists('$(_DotnetTypesSourcePath)')" SkipUnchangedFiles="true" /> + + + + + + all + + + 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..4c69e7792d7529 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 @@ -37,7 +37,6 @@ - true $(WasmNativeWorkload11) $(WasmNativeWorkload10) $(WasmNativeWorkload9) @@ -64,7 +63,6 @@ '$(WasmProfilers)' != '' or '$(RunAOTCompilation)' == 'true' or '$(WasmBuildNative)' == 'true' or - '$(_UsingBlazorOrWasmSdk)' != 'true' or '$(EmccInitialHeapSize)' != '' or '$(EmccMaximumHeapSize)' != '' " >true diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs index 4dcab63cb30848..103e19d974f926 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs @@ -300,10 +300,12 @@ void AssertFile(string suffix) } } - [Theory] - // [InlineData(false)] https://github.com/dotnet/runtime/issues/123477 - [InlineData(true)] - public async Task LibraryModeBuild(bool useWasmSdk) + [Theory, TestCategory("no-workload")] + [InlineData(false, false)] + [InlineData(false, true)] + [InlineData(true, false)] + [InlineData(true, true)] + public async Task LibraryMode(bool useWasmSdk, bool isPublish) { var config = Configuration.Release; ProjectInfo info = CopyTestAsset(config, aot: false, TestAsset.LibraryModeTestApp, "libraryMode"); @@ -313,13 +315,22 @@ public async Task LibraryModeBuild(bool useWasmSdk) { "Microsoft.NET.Sdk.WebAssembly", "Microsoft.NET.Sdk" } }); } - BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk)); + + // Without WASM SDK, the project is a plain library with browser-wasm RID. + // It should build and publish successfully but won't produce a wasm app bundle. + if (isPublish) + PublishProject(info, config, new PublishOptions(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] diff --git a/src/mono/wasm/testassets/WasmBasicTestApp/LazyLibrary/LazyLibrary.csproj b/src/mono/wasm/testassets/WasmBasicTestApp/LazyLibrary/LazyLibrary.csproj index c9ed06860681b0..0e42ce3d859a52 100644 --- a/src/mono/wasm/testassets/WasmBasicTestApp/LazyLibrary/LazyLibrary.csproj +++ b/src/mono/wasm/testassets/WasmBasicTestApp/LazyLibrary/LazyLibrary.csproj @@ -4,6 +4,5 @@ browser-wasm Library true - true