Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5045603
Library mode without workload
maraf Dec 17, 2025
b3709e4
Fix
maraf Dec 17, 2025
991951b
Fix
maraf Dec 17, 2025
5f80cfd
Fix LibraryMode test to expect publish failure without WASM SDK (#122…
Copilot Dec 17, 2025
24c1136
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Dec 18, 2025
5d9b507
Move the test to no-workload
maraf Dec 18, 2025
9985286
Empty _UsingBlazorOrWasmSdk shouldn't trigger requirement for workload
maraf Dec 18, 2025
feb48c4
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Jan 12, 2026
ee5c599
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Jan 20, 2026
3c4b6b2
Merge remote-tracking branch 'origin/main' into maraf/BrowserLibraryM…
maraf Mar 25, 2026
23aa3d8
Uncomment useWasmSdk=false InlineData for LibraryMode test
maraf Mar 26, 2026
d474eb2
Remove unconditional SelfContained=true for browser-wasm from workloa…
maraf Mar 26, 2026
16f727d
Remove PublishTrimmed from WebAssembly.Sdk Sdk.props for library mode
maraf Mar 26, 2026
d4fdeb9
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Mar 27, 2026
b31e81a
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Mar 27, 2026
3298155
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Mar 28, 2026
072cb2c
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Apr 10, 2026
f8ca894
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
lewing Apr 16, 2026
0807980
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Apr 21, 2026
f931287
Merge branch 'main' into maraf/BrowserLibraryModeNoWorkload
maraf Apr 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/mono/browser/build/BrowserWasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@
<ProjectCapability Include="DotNetCoreWeb"/>
</ItemGroup>

<!-- When trimming non-exe projects, root the whole intermediate assembly. -->
<Target Name="_RootEntireIntermediateAssembly" AfterTargets="PrepareForILLink" BeforeTargets="_RunILLink" Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And '$(OutputType)' == 'Library'">
<ItemGroup>
<TrimmerRootAssembly Condition="'%(Identity)' == '$(AssemblyName)'">
<RootMode>all</RootMode>
</TrimmerRootAssembly>
</ItemGroup>
</Target>

<Import Project="$(MSBuildThisFileDirectory)EmSdkRepo.Defaults.props" Condition="'$(WasmUseEMSDK_PATH)' == 'true'" />
<Target Name="_SetupEmscripten" BeforeTargets="_SetupToolchain">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
<TargetArchitecture>wasm</TargetArchitecture>
<TargetOS>browser</TargetOS>
<OutputType Condition="'$(OutputType)' == ''">Exe</OutputType>
<PublishTrimmed Condition="'$(PublishTrimmed)' == ''">true</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -1069,4 +1069,13 @@ Copyright (c) .NET Foundation. All rights reserved.
Condition="Exists('$(_DotnetTypesSourcePath)')"
SkipUnchangedFiles="true" />
</Target>

<!-- When trimming non-exe projects, root the whole intermediate assembly. -->
<Target Name="_RootEntireIntermediateAssembly" AfterTargets="PrepareForILLink" BeforeTargets="_RunILLink" Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And '$(OutputType)' == 'Library'">
<ItemGroup>
<TrimmerRootAssembly Condition="'%(Identity)' == '$(AssemblyName)'">
Copy link
Copy Markdown
Member

@pavelsavara pavelsavara Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opt out per assembly would be good. Maybe existing <IsTrimmable>true</IsTrimmable> ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tell me about the scenario please

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target simulates the default behavior for OutputType=exe => "application assembly is root assembly for trimmer"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not about components in a nuget ? This is "reactor" runtime+app without Main() ?

Isn't that already covered by [JSExport] being a trimmer root ?

<RootMode>all</RootMode>
</TrimmerRootAssembly>
Comment thread
maraf marked this conversation as resolved.
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
<SelfContained>true</SelfContained>
<WasmNativeWorkloadAvailable Condition="'$(TargetsCurrent)' == 'true'">$(WasmNativeWorkload11)</WasmNativeWorkloadAvailable>
<WasmNativeWorkloadAvailable Condition="'$(TargetsNet10)' == 'true'">$(WasmNativeWorkload10)</WasmNativeWorkloadAvailable>
<WasmNativeWorkloadAvailable Condition="'$(TargetsNet9)' == 'true'">$(WasmNativeWorkload9)</WasmNativeWorkloadAvailable>
Expand All @@ -64,7 +63,6 @@
'$(WasmProfilers)' != '' or
'$(RunAOTCompilation)' == 'true' or
'$(WasmBuildNative)' == 'true' or
'$(_UsingBlazorOrWasmSdk)' != 'true' or
'$(EmccInitialHeapSize)' != '' or
'$(EmccMaximumHeapSize)' != '' " >true</_WasmNativeWorkloadNeeded>

Expand Down
25 changes: 18 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +303 to +308
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this test is now tagged with category=no-workload, the workload CI leg will exclude it (Wasm.Build.Tests.csproj passes -notrait category=no-workload when TestUsingWorkloads=true). Since this PR also changes workload behavior (WorkloadManifest.targets.in), consider adding a companion test (without the no-workload trait, or with category=workload) that at least exercises the useWasmSdk=true path in workload mode to guard against regressions.

Copilot uses AI. Check for mistakes.
{
var config = Configuration.Release;
ProjectInfo info = CopyTestAsset(config, aot: false, TestAsset.LibraryModeTestApp, "libraryMode");
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<OutputType>Library</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<UseMonoRuntime>true</UseMonoRuntime>
</PropertyGroup>
</Project>
Loading