diff --git a/eng/native.wasm.targets b/eng/native.wasm.targets
index 69067b6b0a7d41..6df6de93a22b55 100644
--- a/eng/native.wasm.targets
+++ b/eng/native.wasm.targets
@@ -1,7 +1,12 @@
-
+
+
diff --git a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
index f30db447d87201..87d670a9bd11bd 100644
--- a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
+++ b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@@ -1,9 +1,611 @@
-
-
-
+
+
+
+
+
+ true
+
+
+ true
+
+
+ <_CoreCLRInvalidEH Condition="'$(WasmEnableExceptionHandling)' != '' and '$(WasmEnableExceptionHandling)' != 'true'">true
+ <_CoreCLRInvalidSIMD Condition="'$(WasmEnableSIMD)' != '' and '$(WasmEnableSIMD)' != 'true'">true
+ true
+ true
+ emcc
+
+ <_WasmDefaultFlags>-fwasm-exceptions -msimd128
+
+ Build
+ Publish
+
+
+ <_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish
+
+
+ true
+ false
+ true
+
+
+ <_ExeExt Condition="$([MSBuild]::IsOSPlatform('windows'))">.exe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+ <_CoreCLRWasmBuildAppCoreDependsOn>
+ _CoreCLRWasmInitialize;
+ _CoreCLRSetupEmscripten;
+ _CoreCLRPrepareForNativeBuild;
+ _CoreCLRGenerateManagedToNative;
+ _CoreCLRWriteCompileRsp;
+ _CoreCLRCompileNativeSources;
+ _CoreCLRWriteLinkRsp;
+ _CoreCLRLinkNative;
+ _CoreCLRCompleteNativeBuild;
+ _CoreCLREmitAssembliesFinal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %(ResolvedRuntimePack.PackageDirectory)
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackDir), 'runtimes', $(RuntimeIdentifier)))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir)))
+ $([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidDir), 'native'))
+
+ <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForNestedPublish)' != 'true'">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-build'))
+ <_WasmIntermediateOutputPath Condition="'$(WasmBuildingForNestedPublish)' == 'true'">$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm', 'for-publish'))
+
+ <_WasmCompileRsp>$(_WasmIntermediateOutputPath)emcc-compile.rsp
+ <_WasmLinkRsp>$(_WasmIntermediateOutputPath)emcc-link.rsp
+
+
+
+
+
+
+
+
+ <_SystemRuntimePathItem Include="$(MicrosoftNetCoreAppRuntimePackRidDir)lib$(WasmDirSep)net*$(WasmDirSep)System.Runtime.dll" />
+
+
+
+ $([System.IO.Path]::GetDirectoryName(%(_SystemRuntimePathItem.Identity)))
+
+
+
+
+
+
+ <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenSdkToolsPath)' == '' or !Exists('$(EmscriptenSdkToolsPath)'))">%24(EmscriptenSdkToolsPath)=$(EmscriptenSdkToolsPath)
+ <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenNodeToolsPath)' == '' or !Exists('$(EmscriptenNodeToolsPath)'))">%24(EmscriptenNodeToolsPath)=$(EmscriptenNodeToolsPath)
+ <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenUpstreamBinPath)' == '' or !Exists('$(EmscriptenUpstreamBinPath)'))">%24(EmscriptenUpstreamBinPath)=$(EmscriptenUpstreamBinPath)
+
+
+
+ <_ToolchainMissingErrorMessage Condition="'$(EMSDK_PATH)' == '' and '$(EmscriptenSdkToolsPath)' == ''">Could not find emscripten sdk. Either set %24(EMSDK_PATH), or use workloads to get the sdk.
+ <_ToolchainMissingErrorMessage Condition="'$(_ToolchainMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' != 'true' and '$(_EMSDKMissingPaths)' != ''">Emscripten from the workload is missing some paths: $(_EMSDKMissingPaths).
+ <_ToolchainMissingErrorMessage Condition="'$(_ToolchainMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' == 'true' and !Exists($(EMSDK_PATH))">Could not find Emscripten sdk at %24(EMSDK_PATH)=$(EMSDK_PATH).
+ <_ToolchainMissingErrorMessage Condition="'$(_ToolchainMissingErrorMessage)' == '' and '$(_UsingEMSDK_PATH)' == 'true' and '$(_EMSDKMissingPaths)' != ''">Specified Emscripten sdk at %24(EMSDK_PATH)=$(EMSDK_PATH) is missing some paths: $(_EMSDKMissingPaths).
+ <_IsToolchainMissing Condition="'$(_ToolchainMissingErrorMessage)' != ''">true
+
+
+
+
+
+ $([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath)))
+ $([MSBuild]::NormalizeDirectory($(EmscriptenNodeToolsPath)))
+ $([MSBuild]::NormalizeDirectory($(EmscriptenUpstreamBinPath)))
+ $(EmscriptenUpstreamEmscriptenPath)emcc
+
+
+
+
+
+
+
+
+
+
+ <_EmscriptenPrependPATHTrimmed Include="$([MSBuild]::ValueOrDefault('%(EmscriptenPrependPATH.Identity)\', '').TrimEnd('\/'))" />
+
+
+
+
+
+ <_PathSeparator Condition="$([MSBuild]::IsOSPlatform('windows'))">;
+ <_PathSeparator Condition="!$([MSBuild]::IsOSPlatform('windows'))">:
+ <_EmscriptenPrependPATHProperty>@(EmscriptenPrependPATH -> '%(Identity)', '$(_PathSeparator)')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_WasmDevel Condition="'$(_WasmDevel)' == '' and '$(Configuration)' == 'Debug' and '$(WasmBuildingForNestedPublish)' != 'true'">true
+ <_EmccOptimizationFlagDefault Condition="'$(_WasmDevel)' == 'true'">-O0
+ <_EmccOptimizationFlagDefault Condition="'$(_EmccOptimizationFlagDefault)' == '' and '$(Configuration)' == 'Debug' and '$(WasmBuildingForNestedPublish)' != 'true'">-O1
+ <_EmccOptimizationFlagDefault Condition="'$(_EmccOptimizationFlagDefault)' == ''">-O2
+ $(_EmccOptimizationFlagDefault)
+ -O2
+ $(EmccCompileOptimizationFlag)
+
+
+ 134217728
+ 2147483648
+ 5MB
+
+ false
+ <_WasmCompileOutputMessageImportance Condition="'$(EmccVerbose)' == 'true'">Normal
+ <_WasmCompileOutputMessageImportance Condition="'$(EmccVerbose)' != 'true'">Low
+
+
+
+
+ <_ExistingNativeLibrary Include="@(NativeLibrary->Exists())" />
+
+
+
+
+
+ <_EmccCommonFlags Include="$(EmccFlags)" />
+ <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' == 'true'" />
+ <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" />
+ <_EmccCommonFlags Include="-fwasm-exceptions" />
+ <_EmccCommonFlags Include="-msimd128" />
+
+
+
+ <_EmccCFlags Include="$(EmccCompileOptimizationFlag)" />
+ <_EmccCFlags Include="@(_EmccCommonFlags)" />
+ <_EmccCFlags Include="-DGEN_PINVOKE=1" />
+ <_EmccCFlags Include="$(EmccExtraCFlags)" />
+
+
+ <_EmccCFlags Include="-I"$(RepoRoot)src/coreclr/vm/wasm"" Condition="Exists('$(RepoRoot)src/coreclr/vm/wasm/callhelpers.hpp')" />
+ <_EmccCFlags Include="-I"$(RepoRoot)src/native"" Condition="Exists('$(RepoRoot)src/native/minipal/entrypoints.h')" />
+ <_EmccCFlags Include="-include "$(_WasmIntermediateOutputPath)coreclr_compat.h"" />
+
+
+
+
+ <_WasmSourceFileToCompile Remove="@(_WasmSourceFileToCompile)" />
+ <_WasmSourceFileToCompile Include="@(NativeFileReference)" Condition="'%(Extension)' == '.c' or '%(Extension)' == '.cpp'" />
+ <_WasmSourceFileToCompile ObjectFile="$(_WasmIntermediateOutputPath)%(FileName).o" />
+
+ <_WasmSourceFileToCompile Dependencies="$(_WasmCompileRsp);$(_WasmIntermediateOutputPath)coreclr_compat.h" />
+
+
+
+
+ <_WasmNativeFileForLinking Include="@(NativeFileReference)" Condition="'%(Extension)' == '.a' or '%(Extension)' == '.o'" />
+
+
+
+
+
+
+
+ <_WasmPInvokeTablePath>$(_WasmIntermediateOutputPath)pinvoke-table.cpp
+ <_WasmReversePInvokeTablePath>$(_WasmIntermediateOutputPath)reverse-pinvoke-table.cpp
+ <_WasmInterpToNativeTablePath>$(_WasmIntermediateOutputPath)wasm_m2n_invoke.g.cpp
+ <_WasmM2NCachePath>$(_WasmIntermediateOutputPath)m2n_cache.txt
+ <_IsLibraryMode Condition="'$(OutputType)' == 'Library'">true
+ <_IsLibraryMode Condition="'$(_IsLibraryMode)' == ''">false
+
+
+
+
+ <_WasmPInvokeModules Include="%(_WasmNativeFileForLinking.FileName)" Condition="'%(_WasmNativeFileForLinking.ScanForPInvokes)' != 'false'" />
+ <_WasmPInvokeModules Include="libSystem.Native" />
+ <_WasmPInvokeModules Include="libSystem.IO.Compression.Native" />
+ <_WasmPInvokeModules Include="libSystem.Globalization.Native" />
+ <_WasmPInvokeModules Include="libSystem.Native.Browser" />
+ <_WasmPInvokeModules Include="libSystem.Runtime.InteropServices.JavaScript.Native" />
+
+
+
+
+ <_WasmManagedAssemblies Include="@(WasmAssembliesToBundle->Distinct())" />
+
+
+
+
+ <_HasCoreLib Condition="'%(_WasmManagedAssemblies.FileName)%(_WasmManagedAssemblies.Extension)' == 'System.Private.CoreLib.dll'">true
+
+ <_CoreLibPath Condition="'$(_HasCoreLib)' != 'true'">$(MicrosoftNetCoreAppRuntimePackRidNativeDir)System.Private.CoreLib.dll
+ <_CoreLibPath Condition="'$(_HasCoreLib)' != 'true' and !Exists('$(_CoreLibPath)')">$([System.IO.Path]::Combine($(MicrosoftNetCoreAppRuntimePackRidLibTfmDir), 'System.Private.CoreLib.dll'))
+
+
+
+
+
+ <_WasmManagedAssemblies Include="$(_CoreLibPath)" />
+
+
+
+
+
+
+
+
+ <_WasmSourceFileToCompile Include="$(_WasmPInvokeTablePath)" ObjectFile="$(_WasmIntermediateOutputPath)pinvoke-table.o"
+ Dependencies="$(_WasmCompileRsp);$(_WasmIntermediateOutputPath)coreclr_compat.h" />
+ <_WasmSourceFileToCompile Include="$(_WasmInterpToNativeTablePath)" ObjectFile="$(_WasmIntermediateOutputPath)wasm_m2n_invoke.o"
+ Dependencies="$(_WasmCompileRsp);$(_WasmIntermediateOutputPath)coreclr_compat.h" />
+
+
+
+
+
+
+
+
+ <_WasmCoreclrCompatHeader>$(_WasmIntermediateOutputPath)coreclr_compat.h
+
+
+ <_CompatHeaderLines Include="// Auto-generated CoreCLR compat header for app native build" />
+ <_CompatHeaderLines Include="#pragma once" />
+ <_CompatHeaderLines Include="#include <stddef.h>" />
+ <_CompatHeaderLines Include="#include <stdint.h>" />
+ <_CompatHeaderLines Include="#include <stdlib.h>" />
+ <_CompatHeaderLines Include="#include <stdio.h>" />
+ <_CompatHeaderLines Include="// CoreCLR type stubs" />
+ <_CompatHeaderLines Include="#ifndef _CORECLR_COMPAT_TYPES" />
+ <_CompatHeaderLines Include="#define _CORECLR_COMPAT_TYPES" />
+ <_CompatHeaderLines Include="typedef void MethodDesc%3B" />
+ <_CompatHeaderLines Include="typedef uintptr_t PCODE%3B" />
+ <_CompatHeaderLines Include="typedef uint32_t ULONG%3B" />
+ <_CompatHeaderLines Include="#define INTERP_STACK_SLOT_SIZE 8u" />
+ <_CompatHeaderLines Include="#endif" />
+ <_CompatHeaderLines Include="// CoreCLR logging stubs" />
+ <_CompatHeaderLines Include="#define LF_INTEROP 0" />
+ <_CompatHeaderLines Include="#define LL_INFO1000 0" />
+ <_CompatHeaderLines Include="#define LOG(x)" />
+ <_CompatHeaderLines Include="// CoreCLR assertion stubs" />
+ <_CompatHeaderLines Include="#define PORTABILITY_ASSERT(msg) do { fprintf(stderr, "PORTABILITY_ASSERT: %25s", msg)%3B fprintf(stderr, "\n")%3B abort()%3B } while(0)" />
+
+
+
+
+
+
+
+
+ <_WasmCFlags Include="@(_EmccCFlags)" />
+
+
+
+
+
+
+
+
+
+
+
+ <_WasmCompileArguments Remove="@(_WasmCompileArguments)" />
+ <_WasmCompileArguments Include=""@$(_WasmCompileRsp)"" Condition="'$(_WasmCompileRsp)' != ''" />
+
+
+
+
+
+
+
+ <_WasmNativeFileForLinking Include="%(_WasmSourceFileToCompile.ObjectFile)" />
+
+
+
+
+
+
+
+
+ <_EmccExportedRuntimeMethods>"[BROWSER_HOST,@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]"
+ <_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')
+
+
+
+
+
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libBrowserHost.a" />
+
+
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libcoreclr_static.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libnativeresourcestring.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libgcinfo_unix_wasm.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libcoreclrminipal.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libcoreclrpal.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libminipal.a" />
+
+
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Native.Browser.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Runtime.InteropServices.JavaScript.Native.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Native.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Globalization.Native.a" Condition="'$(InvariantGlobalization)' != 'true'" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libicuuc.a" Condition="'$(InvariantGlobalization)' != 'true'" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libicui18n.a" Condition="'$(InvariantGlobalization)' != 'true'" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libicudata.a" Condition="'$(InvariantGlobalization)' != 'true'" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.IO.Compression.Native.a" />
+ <_CoreCLRNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libz.a" />
+
+
+ <_CoreCLRNativeLibs Condition="'$(InvariantTimezone)' != 'true'" Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Native.TimeZoneData.a" />
+ <_CoreCLRNativeLibs Condition="'$(InvariantTimezone)' == 'true'" Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Native.TimeZoneData.Invariant.a" />
+
+
+
+
+ <_CoreCLRJsLibrary Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Native.Browser.js" Kind="js-library" />
+ <_CoreCLRJsLibrary Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Native.Browser.Utils.js" Kind="js-library" />
+ <_CoreCLRJsLibrary Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Runtime.InteropServices.JavaScript.Native.js" Kind="js-library" />
+ <_CoreCLRJsLibrary Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libBrowserHost.js" Kind="js-library" />
+ <_CoreCLRJsLibrary Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)libSystem.Native.Browser.extpost.js" Kind="extern-post-js" />
+
+
+
+
+ <_CoreCLRJsLibrary Include="@(WasmExtraJSFile)" Kind="%(WasmExtraJSFile.Kind)" Condition="'%(WasmExtraJSFile.Kind)' != ''" />
+
+
+
+
+ <_EmccLinkStepArgs Include="$(EmccLinkOptimizationFlag)" />
+ <_EmccLinkStepArgs Include="@(_EmccCommonFlags)" />
+
+
+ <_EmccLinkStepArgs Include="-s EXPORT_ES6=1" />
+ <_EmccLinkStepArgs Include="-lexports.js" />
+
+
+ <_EmccLinkStepArgs Include="-s INITIAL_MEMORY=$(WasmInitialHeapSize)" />
+ <_EmccLinkStepArgs Include="-s MAXIMUM_MEMORY=$(EmccMaximumHeapSize)" />
+ <_EmccLinkStepArgs Include="-s ALLOW_MEMORY_GROWTH=1" />
+ <_EmccLinkStepArgs Include="-s STACK_SIZE=$(EmccStackSize)" />
+ <_EmccLinkStepArgs Include="-s WASM_BIGINT=1" />
+
+
+ <_EmccLinkStepArgs Include="-s MODULARIZE=1" />
+ <_EmccLinkStepArgs Include="-s EXIT_RUNTIME=1" />
+ <_EmccLinkStepArgs Include="-s ALLOW_TABLE_GROWTH=1" />
+ <_EmccLinkStepArgs Include="-s EXPORT_NAME=createDotnetRuntime" />
+ <_EmccLinkStepArgs Include="-s ENVIRONMENT=web,webview,worker,node,shell" />
+
+
+ <_EmccLinkStepArgs Condition="'$(Configuration)' == 'Debug'" Include="-s LLD_REPORT_UNDEFINED" />
+ <_EmccLinkStepArgs Condition="'$(Configuration)' == 'Debug'" Include="-s ERROR_ON_UNDEFINED_SYMBOLS=1" />
+ <_EmccLinkStepArgs Include="--emit-symbol-map" />
+
+
+ <_EmccLinkStepArgs Condition="'$(Configuration)' == 'Debug'" Include="-s ASSERTIONS=1" />
+
+
+ <_EmccLinkStepArgs Include="-s EXPORTED_RUNTIME_METHODS=$(_EmccExportedRuntimeMethods)" />
+ <_EmccLinkStepArgs Include="-s EXPORTED_FUNCTIONS=$(_EmccExportedFunctions)" />
+
+
+ <_EmccLinkStepArgs Include="--%(_CoreCLRJsLibrary.Kind) "%(_CoreCLRJsLibrary.Identity)"" />
+
+
+ <_EmccLinkStepArgs Include=""%(_WasmNativeFileForLinking.Identity)"" />
+
+
+ <_EmccLinkStepArgs Include=""%(_CoreCLRNativeLibs.Identity)"" />
+
+
+ <_EmccLinkStepArgs Include="-o "$(_WasmIntermediateOutputPath)dotnet.native.js"" />
+
+
+ <_EmccLinkStepArgs Include="$(EmccExtraLDFlags)" />
+
+
+ <_EmccLinkStepArgs Include="-Wl,-error-limit=0" />
+
+
+
+
+ <_WasmLinkDependencies Include="@(_WasmNativeFileForLinking)" />
+ <_WasmLinkDependencies Include="@(_CoreCLRNativeLibs)" />
+ <_WasmLinkDependencies Include="@(_CoreCLRJsLibrary)" />
+ <_WasmLinkDependencies Include="$(_WasmLinkRsp)" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" />
+ <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" Condition="@(WasmAssembliesToBundle->Count()) > 0" />
+
+
+ <_WasmSatelliteAssemblies Remove="@(_WasmSatelliteAssemblies)" />
+ <_WasmSatelliteAssemblies Include="@(_WasmAssembliesInternal)" />
+ <_WasmSatelliteAssemblies Remove="@(_WasmSatelliteAssemblies)" Condition="!$([System.String]::Copy('%(Identity)').EndsWith('.resources.dll'))" />
+ <_WasmSatelliteAssemblies CultureName="$([System.IO.Directory]::GetParent('%(Identity)').Name)" />
+ <_WasmAssembliesInternal Remove="@(_WasmSatelliteAssemblies)" />
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/mono/sample/wasm/Directory.Build.props b/src/mono/sample/wasm/Directory.Build.props
index 7a509c489b84c6..3bf42bde850027 100644
--- a/src/mono/sample/wasm/Directory.Build.props
+++ b/src/mono/sample/wasm/Directory.Build.props
@@ -46,6 +46,14 @@
+
+
+ $(Nested_RuntimeFlavor)
+
+
diff --git a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
index 4e993991471be5..7cc84e8dbf8841 100644
--- a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
@@ -36,6 +36,8 @@ public abstract class BuildTestBase : IClassFixture
+ /// Ensures the xharness CLI is available as a local dotnet tool by running
+ /// dotnet tool restore if needed. This is a no-op when
+ /// XHARNESS_CLI_PATH is set (CI provides the tool externally).
+ ///
+ protected static void EnsureXHarnessAvailable()
+ {
+ if (!string.IsNullOrEmpty(EnvironmentVariables.XHarnessCliPath))
+ return;
+
+ if (s_xharnessToolRestored)
+ return;
+
+ lock (s_xharnessRestoreLock)
+ {
+ if (s_xharnessToolRestored)
+ return;
+
+ // Find repo root by walking up to NuGet.config
+ DirectoryInfo? repoRoot = new(AppContext.BaseDirectory);
+ while (repoRoot is not null && !File.Exists(Path.Combine(repoRoot.FullName, "NuGet.config")))
+ repoRoot = repoRoot.Parent;
+
+ if (repoRoot is null)
+ throw new InvalidOperationException("Could not find repo root (directory containing NuGet.config) to restore xharness tool");
+
+ Console.WriteLine($"[xharness] Restoring dotnet tools from {repoRoot.FullName} using {s_buildEnv.DotNet}");
+
+ var psi = new ProcessStartInfo
+ {
+ FileName = s_buildEnv.DotNet,
+ Arguments = "tool restore",
+ WorkingDirectory = repoRoot.FullName,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ UseShellExecute = false
+ };
+ psi.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "1";
+
+ using var process = Process.Start(psi)
+ ?? throw new InvalidOperationException("Failed to start 'dotnet tool restore' process");
+
+ var stdoutTask = process.StandardOutput.ReadToEndAsync();
+ var stderrTask = process.StandardError.ReadToEndAsync();
+ process.WaitForExit();
+
+ string stdout = stdoutTask.Result;
+ string stderr = stderrTask.Result;
+
+ if (process.ExitCode != 0)
+ throw new InvalidOperationException(
+ $"'dotnet tool restore' failed with exit code {process.ExitCode}.\nStdout: {stdout}\nStderr: {stderr}");
+
+ Console.WriteLine($"[xharness] Tool restore completed successfully");
+ s_xharnessToolRestored = true;
+ }
+ }
+
public static IEnumerable> ConfigWithAOTData(bool aot, Configuration config = Configuration.Undefined)
{
if (config == Configuration.Undefined)
diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs
index 3a42708e1f4941..0760f1d12d2f62 100644
--- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs
@@ -89,6 +89,8 @@ public ProjectInfo CreateWasmTemplateProject(
.ExecuteWithCapturedOutput($"new {template.ToString().ToLower()} {extraArgs}")
.EnsureSuccessful();
+ AddCoreClrProjectProperties(ref extraProperties, ref extraItems, ref insertAtEnd);
+
string projectFilePath = Path.Combine(_projectDir, $"{projectName}.csproj");
UpdateProjectFile(projectFilePath, runAnalyzers, extraProperties, extraItems, insertAtEnd);
return new ProjectInfo(projectName, projectFilePath, logPath, nugetDir);
@@ -124,35 +126,7 @@ protected ProjectInfo CopyTestAsset(
""";
}
- if (s_buildEnv.IsCoreClrRuntime)
- {
- // TODO-WASM: https://github.com/dotnet/sdk/issues/51213
- string versionSuffix = s_buildEnv.IsRunningOnCI ? "ci" : "dev";
-
- extraProperties +=
- """
- false
- """;
- extraItems +=
- $$"""
-
- 11.0.0-{{versionSuffix}}
- 11.0.0-{{versionSuffix}}
- 11.0.0-{{versionSuffix}}
- browser-wasm;%(RuntimePackRuntimeIdentifiers)
-
- """;
- insertAtEnd +=
- $$"""
-
-
-
- 11.0.0-{{versionSuffix}}
-
-
-
- """;
- }
+ AddCoreClrProjectProperties(ref extraProperties, ref extraItems, ref insertAtEnd);
UpdateProjectFile(projectFilePath, runAnalyzers, extraProperties, extraItems, insertAtEnd);
return new ProjectInfo(asset.Name, projectFilePath, logPath, nugetDir);
@@ -166,6 +140,39 @@ private void UpdateProjectFile(string projectFilePath, bool runAnalyzers, string
AddItemsPropertiesToProject(projectFilePath, extraProperties, extraItems, insertAtEnd);
}
+ private static void AddCoreClrProjectProperties(ref string extraProperties, ref string extraItems, ref string insertAtEnd)
+ {
+ if (!s_buildEnv.IsCoreClrRuntime)
+ return;
+
+ string versionSuffix = s_buildEnv.IsRunningOnCI ? "ci" : "dev";
+
+ extraProperties +=
+ """
+ false
+ false
+ """;
+ extraItems +=
+ $$"""
+
+ 11.0.0-{{versionSuffix}}
+ 11.0.0-{{versionSuffix}}
+ 11.0.0-{{versionSuffix}}
+ browser-wasm;%(RuntimePackRuntimeIdentifiers)
+
+ """;
+ insertAtEnd +=
+ $$"""
+
+
+
+ 11.0.0-{{versionSuffix}}
+
+
+
+ """;
+ }
+
public virtual (string projectDir, string buildOutput) PublishProject(
ProjectInfo info,
Configuration configuration,
@@ -351,6 +358,8 @@ private async Task BrowserRun(RunOptions runOptions)
runOptions = runOptions with { CustomBundleDir = Path.GetFullPath(Path.Combine(GetBinFrameworkDir(runOptions.Configuration, forPublish: true), "..", "public")) };
}
+ EnsureXHarnessAvailable();
+
return runOptions.Host switch
{
RunHost.DotnetRun =>
diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj
index 734d7e732c379a..bb85c35489f1c2 100644
--- a/src/native/corehost/corehost.proj
+++ b/src/native/corehost/corehost.proj
@@ -190,6 +190,8 @@
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.js" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.js.symbols" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.wasm" />
+
+ <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(MSBuildThisFileDirectory)..\libs\System.Native.Browser\libSystem.Native.Browser.extpost.js" />