Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2cd8db0
Copy native wasm files to runtime pack
maraf Dec 12, 2025
0f58a1c
Register CoreCLR.sfxproj to get RuntimeList.xml
maraf Dec 12, 2025
301d804
WasmTestRunner and WasmSymbolicator
maraf Dec 12, 2025
61dbd7f
Don't import Mono NativeBuild targets for CoreCLR
maraf Dec 12, 2025
8066b26
Mono Sample with CoreCLR
maraf Dec 12, 2025
7d2620b
Defaults for CoreCLR on wasm
maraf Dec 12, 2025
15a1b5d
Placeholder for CoreCLR native build
maraf Dec 12, 2025
ff67465
Append .dll extention to mainAssemblyName
maraf Dec 12, 2025
8212ed6
Copy test runners
maraf Dec 12, 2025
5d4e456
Merge remote-tracking branch 'upstream/main' into BrowserCoreClrInTree
maraf Dec 15, 2025
55f90fb
Wasm.Build.Tests SDK
maraf Dec 15, 2025
63af39e
Skip InstallWorkloadFromArtifacts if no workloads selected
maraf Dec 16, 2025
2a736b1
WBT running main
maraf Dec 16, 2025
a7ee811
Prepare for skipping files from coreclr runtime pack
maraf Dec 16, 2025
84b8780
Pass DefaultTargetFramework to running browser
maraf Dec 16, 2025
5117784
Default to TestUsingWorkloads=false when RuntimeFlavor=CoreCLR
maraf Dec 16, 2025
54bc98f
Publish build artifacts
maraf Dec 16, 2025
03d4bcd
Include SDK related packages in coreclr-packages.proj
maraf Dec 17, 2025
e4baffa
Build Wasm.Build.Tests on CI for CoreCLR
maraf Dec 17, 2025
e2717cb
Build Wasm.Build.Tests on CI for CoreCLR (unique name)
maraf Dec 17, 2025
1c01837
Fix paths
maraf Dec 17, 2025
e9918f1
Build Wasm.Build.Tests on CI for CoreCLR (configuration=debug)
maraf Dec 17, 2025
ecdf53e
Build Wasm.Build.Tests on CI for CoreCLR (TestUsingWorkloads=false)
maraf Dec 17, 2025
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
Prev Previous commit
Next Next commit
WBT running main
  • Loading branch information
maraf committed Dec 16, 2025
commit 2a736b129ba03fb2a44340f785efdc5716e4879c
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ public class TestAsset
public static readonly TestAsset BlazorBasicTestApp = new() { Name = "BlazorBasicTestApp", RunnableProjectSubPath = "App" };
public static readonly TestAsset LibraryModeTestApp = new() { Name = "LibraryMode" };
public static readonly TestAsset BlazorWebWasm = new() { Name = "BlazorWebWasm", RunnableProjectSubPath = "BlazorWebWasm" };
public static readonly TestAsset WasmBrowserRunMainOnly = new() { Name = "WasmBrowserRunMainOnly" };
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public BuildEnvironment()
$" {nameof(IsRunningOnCI)} is true but {nameof(IsWorkloadWithMultiThreadingForDefaultFramework)} is false.");
}

UseWebcil = EnvironmentVariables.UseWebcil;
UseWebcil = EnvironmentVariables.UseWebcil && EnvironmentVariables.RuntimeFlavor != "CoreCLR"; // TODO-WASM: CoreCLR support for Webcil

if (EnvironmentVariables.BuiltNuGetsPath is null || !Directory.Exists(EnvironmentVariables.BuiltNuGetsPath))
throw new Exception($"Cannot find 'BUILT_NUGETS_PATH={EnvironmentVariables.BuiltNuGetsPath}'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ internal static class EnvironmentVariables
internal static readonly string? SdkDirName = Environment.GetEnvironmentVariable("SDK_DIR_NAME");
internal static readonly string? WasiSdkPath = Environment.GetEnvironmentVariable("WASI_SDK_PATH");
internal static readonly bool WorkloadsTestPreviousVersions = Environment.GetEnvironmentVariable("WORKLOADS_TEST_PREVIOUS_VERSIONS") is "true";
internal static readonly string? RuntimeFlavor = Environment.GetEnvironmentVariable("RUNTIME_FLAVOR_FOR_TESTS");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ protected ProjectInfo CopyTestAsset(
""";
}

if (EnvironmentVariables.RuntimeFlavor == "CoreCLR")
{
// TODO-WASM: https://github.com/dotnet/sdk/issues/51213
string versionSuffix = s_buildEnv.IsRunningOnCI ? "ci" : "dev";

extraProperties +=
"""
<UseMonoRuntime>false</UseMonoRuntime>
""";
extraItems +=
$$"""
<KnownFrameworkReference Update="Microsoft.NETCore.App">
<TargetingPackVersion>11.0.0-{{versionSuffix}}</TargetingPackVersion>
<DefaultRuntimeFrameworkVersion>11.0.0-{{versionSuffix}}</DefaultRuntimeFrameworkVersion>
<LatestRuntimeFrameworkVersion>11.0.0-{{versionSuffix}}</LatestRuntimeFrameworkVersion>
<RuntimePackRuntimeIdentifiers>browser-wasm;%(RuntimePackRuntimeIdentifiers)</RuntimePackRuntimeIdentifiers>
</KnownFrameworkReference>
""";
}

UpdateProjectFile(projectFilePath, runAnalyzers, extraProperties, extraItems, insertAtEnd);
return new ProjectInfo(asset.Name, projectFilePath, logPath, nugetDir);
}
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set WORKLOAD_PACKS_VER=$(PackageVersionForWorkloadManifests)" />
</ItemGroup>

<ItemGroup Condition="'$(RuntimeFlavor)' != ''">
<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export RUNTIME_FLAVOR=$(RuntimeFlavor)" />
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set RUNTIME_FLAVOR=$(RuntimeFlavor)" />
</ItemGroup>

<ItemGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<!-- TEST_USING_WORKLOADS - this is set per helix job, in sendtohelixhelp.proj -->
<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export BASE_DIR=%24{HELIX_CORRELATION_PAYLOAD}" />
Expand All @@ -97,6 +102,7 @@
<_XUnitTraitArg Condition="'$(TestUsingWorkloads)' != 'true'">-trait category=no-workload</_XUnitTraitArg>
<_XUnitTraitArg Condition="'$(WasmFingerprintAssets)' == 'false'">-trait category=no-fingerprinting</_XUnitTraitArg>
<_XUnitTraitArg Condition="'$(WasmBundlerFriendlyBootConfig)' == 'true'">-trait category=bundler-friendly</_XUnitTraitArg>
<_XUnitTraitArg Condition="'$(RuntimeFlavor)' == 'CoreCLR'">-trait category=$(RuntimeFlavor)</_XUnitTraitArg>
</PropertyGroup>

<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
Expand Down
27 changes: 27 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Specialized;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Wasm.Build.Tests;

public class WasmBrowserRunMainOnly(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) : WasmTemplateTestsBase(output, buildContext)
{
[Fact, TestCategory("coreclr")]
public async Task RunMainOnly()
{
Configuration config = Configuration.Debug;

ProjectInfo info = CopyTestAsset(config, false, TestAsset.WasmBrowserRunMainOnly, $"WasmBrowserRunMainOnly");
PublishProject(info, config);

var result = await RunForPublishWithWebServer(new BrowserRunOptions(
Configuration: config
));

Assert.Collection(
result.TestOutput,
m => Assert.Equal("Hello from WasmBrowserRunMainOnly!", m)
);
}
}
3 changes: 3 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ if [%WASM_BUNDLER_FRIENDLY_BOOT_CONFIG%] == [true] (
) else (
set USE_JAVASCRIPT_BUNDLER_FOR_TESTS=false
)
if [%RUNTIME_FLAVOR%] NEQ [] (
set RUNTIME_FLAVOR_FOR_TESTS=%RUNTIME_FLAVOR%
)

if [%HELIX_CORRELATION_PAYLOAD%] NEQ [] (
robocopy /mt /np /nfl /NDL /nc /e %BASE_DIR%\%SDK_DIR_NAME% %EXECUTION_DIR%\%SDK_DIR_NAME%
Expand Down
4 changes: 4 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ function set_env_vars()
export USE_JAVASCRIPT_BUNDLER_FOR_TESTS=false
fi

if [[ -n "$RUNTIME_FLAVOR" ]]; then
export RUNTIME_FLAVOR_FOR_TESTS=$RUNTIME_FLAVOR
fi

local _SDK_DIR=
if [[ -n "$HELIX_WORKITEM_UPLOAD_ROOT" ]]; then
cp -r $BASE_DIR/$SDK_DIR_NAME $EXECUTION_DIR
Expand Down
7 changes: 7 additions & 0 deletions src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

TestOutput.WriteLine("Hello from WasmBrowserRunMainOnly!");

// TODO-WASM: CoreCLR currently doesn't exit from Main
Console.WriteLine("WASM EXIT 0");
return 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

[assembly:System.Runtime.Versioning.SupportedOSPlatform("browser")]
18 changes: 18 additions & 0 deletions src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

public static class TestOutput
{
public static void WriteLine(string message)
{
Console.WriteLine("TestOutput -> " + message);
}

public static void WriteLine(object message)
{
Console.Write("TestOutput -> ");
Console.WriteLine(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
<PropertyGroup>
<TargetFramework>net11.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OverrideHtmlAssetPlaceholders>true</OverrideHtmlAssetPlaceholders>
</PropertyGroup>

<ItemGroup>
<StaticWebAssetFingerprintPattern Include="JS" Pattern="*.js" Expression="#[.{fingerprint}]!" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<!-- Licensed to the .NET Foundation under one or more agreements. -->
<!-- The .NET Foundation licenses this file to you under the MIT license. -->
<html>

<head>
<title>WasmBrowserRunMainOnly</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preload" id="webassembly" />
<script type="importmap"></script>
<script type='module' src="main#[.{fingerprint}].js"></script>
</head>

<body>
</body>

</html>
14 changes: 14 additions & 0 deletions src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { dotnet } from './_framework/dotnet.js'

await dotnet.create();

try {
await dotnet.run();
console.log("WASM EXIT 0");
} catch (err) {
console.error(err);
console.log("WASM EXIT 1");
}
Loading