Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -49,15 +49,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)' == '@(IntermediateAssembly)'">
<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 @@ -932,4 +932,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)' == '@(IntermediateAssembly)'">
<RootMode>all</RootMode>
</TrimmerRootAssembly>
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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 @@ -296,10 +296,12 @@ void AssertFile(string suffix)
}
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task LibraryModeBuild(bool useWasmSdk)
[Theory, TestCategory("no-workload")]
[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");
Expand All @@ -309,13 +311,22 @@ public async Task LibraryModeBuild(bool useWasmSdk)
{ "Microsoft.NET.Sdk.WebAssembly", "Microsoft.NET.Sdk" }
});
}
BuildProject(info, config, new BuildOptions(AssertAppBundle: useWasmSdk));

// 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));

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
Loading