diff --git a/eng/pipelines/common/templates/browser-wasm-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-build-tests.yml index 0963ebed5a5350..39fca50137411f 100644 --- a/eng/pipelines/common/templates/browser-wasm-build-tests.yml +++ b/eng/pipelines/common/templates/browser-wasm-build-tests.yml @@ -112,6 +112,7 @@ jobs: /p:WasmSkipMissingRuntimePackBuild=true /p:PreparePackagesForWorkloadInstall=false /p:WorkloadsTestPreviousVersions=$(workloadsTestPreviousVersionsVar) + /p:RuntimeFlavor=Mono timeoutInMinutes: 180 condition: >- or( diff --git a/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml new file mode 100644 index 00000000000000..aa776908d79d07 --- /dev/null +++ b/eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml @@ -0,0 +1,128 @@ +# Depends on other builds to get runtime packs, and nugets +# And then runs Wasm.Build.Tests +parameters: + alwaysRun: false + isExtraPlatformsBuild: false + isWasmOnlyBuild: false + platforms: [] + shouldContinueOnError: false + extraBuildArgs: '' + +jobs: + +- ${{ each platform in parameters.platforms }}: + - template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/global-build-job.yml + helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml + buildConfig: Debug + runtimeFlavor: CoreCLR + platforms: + - ${{ platform }} + shouldContinueOnError: ${{ parameters.shouldContinueOnError }} + variables: + # map dependencies variables to local variables + - name: alwaysRunVar + value: ${{ parameters.alwaysRun }} + - name: workloadsTestPreviousVersionsVar + value: false +# value: $[ +# or( +# eq(variables['Build.SourceBranchName'], 'main'), +# eq(variables['System.PullRequest.TargetBranch'], 'main')) +# ] + - name: wbtProjectArg + ${{ if eq(platform, 'browser_wasm_win') }}: + value: '-projects' + ${{ else }}: + value: '--projects' + - name: shouldRunOnDefaultPipelines + value: $(shouldRunWasmBuildTestsOnDefaultPipeline) + + jobParameters: + dependsOn: + - ${{ if eq(platform, 'browser_wasm') }}: + - build_browser_wasm_linux_Debug_AllSubsets_CoreCLR + - ${{ if eq(platform, 'browser_wasm_win') }}: + - build_browser_wasm_windows_Debug_AllSubsets_CoreCLR + isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }} + testGroup: innerloop + nameSuffix: CoreCLR_WasmBuildTests + + preBuildSteps: + # Download single threaded runtime packs, and tasks needed to build WBT + - task: DownloadBuildArtifacts@0 + displayName: Download built nugets for singlethreaded runtime + inputs: + buildType: current + artifactName: 'BuildArtifacts_browser_wasm_$(_hostedOs)_Debug_AllSubsets_CoreCLR' + downloadType: single + downloadPath: '$(Build.SourcesDirectory)/artifacts' + + - task: CopyFiles@2 + displayName: Copy single threaded assets + inputs: + SourceFolder: '$(Build.SourcesDirectory)/artifacts/BuildArtifacts_browser_wasm_$(_hostedOs)_Debug_AllSubsets_CoreCLR' + TargetFolder: '$(Build.SourcesDirectory)/artifacts' + CleanTargetFolder: false + + # Download for multi-threaded + # - task: DownloadBuildArtifacts@0 + # displayName: Download built nugets for multi-threaded runtime + # inputs: + # buildType: current + # artifactName: BuildArtifacts_browser_wasm_$(_hostedOs)_Release_MultiThreaded_BuildOnly + # downloadType: single + # downloadPath: '$(Build.SourcesDirectory)/artifacts' + + # - task: CopyFiles@2 + # displayName: Copy multithreading runtime pack + # inputs: + # SourceFolder: '$(Build.SourcesDirectory)/artifacts/BuildArtifacts_browser_wasm_$(_hostedOs)_Release_MultiThreaded_BuildOnly' + # Contents: packages/$(_BuildConfig)/Shipping/Microsoft.NETCore.App.Runtime.Mono.multithread.* + # TargetFolder: '$(Build.SourcesDirectory)/artifacts' + # CleanTargetFolder: false + + # Download WBT - TODO-WASM: This points to "mono" build, altough + - task: DownloadBuildArtifacts@0 + displayName: Download Wasm.Build.Tests + inputs: + buildType: current + artifactName: WasmBuildTests_$(_hostedOs)_AllSubsets_CoreCLR + downloadType: single + downloadPath: '$(Build.SourcesDirectory)/artifacts' + + - task: CopyFiles@2 + displayName: Copy Wasm.Build.Tests archive + inputs: + SourceFolder: '$(Build.SourcesDirectory)/artifacts/WasmBuildTests_$(_hostedOs)_AllSubsets_CoreCLR' + Contents: helix/** + TargetFolder: '$(Build.SourcesDirectory)/artifacts' + CleanTargetFolder: false + + # build WBT + buildArgs: >- + $(wbtProjectArg) $(Build.SourcesDirectory)/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj + /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Build.binlog + /p:Configuration=$(_BuildConfig) + /p:TestUsingWorkloads=false + /p:InstallWorkloadForTesting=true + /p:WasmSkipMissingRuntimePackBuild=true + /p:PreparePackagesForWorkloadInstall=false + /p:WorkloadsTestPreviousVersions=$(workloadsTestPreviousVersionsVar) + /p:RuntimeFlavor=CoreCLR + timeoutInMinutes: 180 + condition: >- + or( + eq(variables['alwaysRunVar'], true), + eq(variables['isDefaultPipeline'], variables['shouldRunWasmBuildTestsOnDefaultPipeline'])) + + # extra steps, run tests + postBuildSteps: + - template: /eng/pipelines/libraries/helix.yml + parameters: + creator: dotnet-bot + testRunNamePrefixSuffix: CoreCLR_$(_BuildConfig)_$(_hostedOs) + extraHelixArguments: /p:BrowserHost=$(_hostedOs) + scenarios: + - buildwasmapps diff --git a/eng/pipelines/runtime-linker-tests.yml b/eng/pipelines/runtime-linker-tests.yml index 3f2e6c1da8b5d1..e5fe67fbc0b595 100644 --- a/eng/pipelines/runtime-linker-tests.yml +++ b/eng/pipelines/runtime-linker-tests.yml @@ -135,5 +135,5 @@ extends: postBuildSteps: - template: /eng/pipelines/libraries/execute-trimming-tests-steps.yml parameters: - extraTestArgs: '/p:WasmBuildNative=false' + extraTestArgs: '/p:WasmBuildNative=false /p:RuntimeFlavor=Mono' runAotTests: false diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index ee2b9da081d13e..0fa511074568c8 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -112,12 +112,16 @@ extends: - browser_wasm_win jobParameters: nameSuffix: AllSubsets_CoreCLR - buildArgs: -s clr+libs+packs -c $(_BuildConfig) -lc Release + buildArgs: -s clr+libs+libs.tests+packs -c $(_BuildConfig) -lc Release /p:TestAssemblies=false /p:TestWasmBuildTests=true /p:ArchiveTests=true /p:InstallWorkloadForTesting=false timeoutInMinutes: 120 postBuildSteps: - template: /eng/pipelines/common/templates/runtimes/build-runtime-tests.yml parameters: testBuildArgs: test JIT/interpreter/Interpreter.csproj + - template: /eng/pipelines/common/wasm-post-build-steps.yml + parameters: + publishArtifactsForWorkload: true + publishWBT: true extraVariablesTemplates: - template: /eng/pipelines/common/templates/runtimes/test-variables.yml parameters: @@ -130,6 +134,15 @@ extends: eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_wasm_coreclr_runtimetests.containsChange'], true), eq(variables['isRollingBuild'], true)) + # Browser Wasm.Build.Tests + - template: /eng/pipelines/common/templates/browser-wasm-coreclr-build-tests.yml + parameters: + platforms: + - browser_wasm + - browser_wasm_win + alwaysRun: ${{ variables.isRollingBuild }} + extraBuildArgs: /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + # # Build CoreCLR and Libraries with Libraries tests # For running libraries tests and installer tests diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets index 5e88f3b4922cbd..d7426f7d4339a4 100644 --- a/eng/testing/tests.browser.targets +++ b/eng/testing/tests.browser.targets @@ -20,6 +20,10 @@ ReadWasmNativeAssetsFromFileSystem; UpdateWasmNativeAssetOriginalItemSpec + + $(ResolveWasmOutputsDependsOn); + AddTestRunnersToReferenceCopyLocalPaths + $([MSBuild]::NormalizeDirectory($(BrowserProjectRoot), 'emsdk')) @@ -176,6 +180,24 @@ + + + <_runnerFilesToBuild Include="$(WasmTestRunnerDir)*" /> + + + <_resolvedFilesToBuildToFileName Include="@(ReferenceCopyLocalPaths -> '%(FileName)%(Extension)')" /> + + <_runnerFilesToBuildToFileName Include="@(_runnerFilesToBuild -> '%(FileName)%(Extension)')"> + %(Identity) + + <_runnerFilesToBuildToFileName Remove="@(_resolvedFilesToBuildToFileName)" /> + + + + + diff --git a/eng/testing/workloads-browser.targets b/eng/testing/workloads-browser.targets index 4bb3ddb7502fdf..41b4ae6dd37959 100644 --- a/eng/testing/workloads-browser.targets +++ b/eng/testing/workloads-browser.targets @@ -8,7 +8,7 @@ - + - + <_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" /> <_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.*.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" /> <_RuntimePackNugetAvailable Remove="@(_RuntimePackNugetAvailable)" Condition="$([System.String]::new('%(_RuntimePackNugetAvailable.FileName)').EndsWith('.symbols'))" /> - - - - - + + + <_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" /> + <_RuntimePackNugetAvailable Remove="@(_RuntimePackNugetAvailable)" Condition="$([System.String]::new('%(_RuntimePackNugetAvailable.FileName)').EndsWith('.symbols'))" /> + + + + + + + Descriptor="AOT Cross compiler" + Condition="'$(RuntimeFlavor)' == 'Mono'" /> diff --git a/src/coreclr/.nuget/coreclr-packages.proj b/src/coreclr/.nuget/coreclr-packages.proj index 609e6884946c88..587ddf302627d0 100644 --- a/src/coreclr/.nuget/coreclr-packages.proj +++ b/src/coreclr/.nuget/coreclr-packages.proj @@ -12,5 +12,13 @@ + + + + + + + + diff --git a/src/coreclr/inc/clrconfigvalues.h b/src/coreclr/inc/clrconfigvalues.h index 331d3a506d56ea..17c5aa40c61dc6 100644 --- a/src/coreclr/inc/clrconfigvalues.h +++ b/src/coreclr/inc/clrconfigvalues.h @@ -711,7 +711,12 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableRiscV64Zbs, W("EnableRiscV64 #endif // Runtime-async +#if defined(TARGET_BROWSER) +// WASM-TODO: https://github.com/dotnet/runtime/issues/121064 +RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_RuntimeAsync, W("RuntimeAsync"), 0, "Enables runtime async method support") +#else RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_RuntimeAsync, W("RuntimeAsync"), 1, "Enables runtime async method support") +#endif // TARGET_BROWSER /// /// Uncategorized diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 39433337207a3e..7dd51b6d0411ae 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -22,13 +22,16 @@ - - + + + diff --git a/src/libraries/sendtohelix-browser.targets b/src/libraries/sendtohelix-browser.targets index 4490122a05e513..c90dd51c6b3974 100644 --- a/src/libraries/sendtohelix-browser.targets +++ b/src/libraries/sendtohelix-browser.targets @@ -135,6 +135,7 @@ <_XUnitTraitArg Condition="'$(TestUsingWorkloads)' != 'true'">-trait category=no-workload <_XUnitTraitArg Condition="'$(WasmFingerprintAssets)' == 'false'">$(_XUnitTraitArg) -trait category=no-fingerprinting <_XUnitTraitArg Condition="'$(WasmBundlerFriendlyBootConfig)' == 'true'">$(_XUnitTraitArg) -trait category=bundler-friendly + <_XUnitTraitArg Condition="'$(RuntimeFlavor)' == 'CoreCLR'">-trait category=$(RuntimeFlavor) diff --git a/src/libraries/sendtohelix.proj b/src/libraries/sendtohelix.proj index c121c3c009d51b..4107809be25b7c 100644 --- a/src/libraries/sendtohelix.proj +++ b/src/libraries/sendtohelix.proj @@ -85,10 +85,10 @@ - <_TestUsingWorkloadsValues Include="true;false" /> - <_TestUsingWebcilValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" /> - <_TestUsingFingerprintingValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" /> - <_TestUsingJavascriptBundlerValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" /> + <_TestUsingWorkloadsValues Include="false" /> + <_TestUsingWorkloadsValues Include="true" Condition="'$(RuntimeFlavor)' == 'Mono'" /> + <_TestUsingWebcilValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> + <_TestUsingFingerprintingValues Include="true;false" Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'Mono'" /> <_TestUsingCrossProductValuesTemp Include="@(_TestUsingWorkloadsValues)"> @@ -106,7 +106,7 @@ <_TestUsingCrossProductValues Remove="@(_TestUsingCrossProductValues)" Condition="'%(_TestUsingCrossProductValues.Workloads)' == 'false' and '%(_TestUsingCrossProductValues.Fingerprinting)' == 'false'" /> - <_TestUsingCrossProductValues Include="JavaScriptBundlerFriendly"> + <_TestUsingCrossProductValues Include="JavaScriptBundlerFriendly" Condition="'$(RuntimeFlavor)' == 'Mono'"> true true true diff --git a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets new file mode 100644 index 00000000000000..f30db447d87201 --- /dev/null +++ b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/mono/browser/build/WasmApp.InTree.props b/src/mono/browser/build/WasmApp.InTree.props index 2fef6aa17d9993..33a54b83c15236 100644 --- a/src/mono/browser/build/WasmApp.InTree.props +++ b/src/mono/browser/build/WasmApp.InTree.props @@ -12,7 +12,15 @@ - + + + + + false + false + false + false + library diff --git a/src/mono/browser/build/WasmApp.InTree.targets b/src/mono/browser/build/WasmApp.InTree.targets index fd7704093652c9..ab86fb1780ecc7 100644 --- a/src/mono/browser/build/WasmApp.InTree.targets +++ b/src/mono/browser/build/WasmApp.InTree.targets @@ -7,7 +7,8 @@ - + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets b/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets index 550672aa417d8a..aa817442bf6cd9 100755 --- a/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets @@ -197,6 +197,7 @@ + diff --git a/src/mono/sample/wasm/Directory.Build.targets b/src/mono/sample/wasm/Directory.Build.targets index baa756debe46da..d381a6bf769421 100644 --- a/src/mono/sample/wasm/Directory.Build.targets +++ b/src/mono/sample/wasm/Directory.Build.targets @@ -1,4 +1,9 @@ + + + $(Nested_RuntimeFlavor) + + @@ -37,6 +42,10 @@ + + + + false + """; + extraItems += + $$""" + + 11.0.0-{{versionSuffix}} + 11.0.0-{{versionSuffix}} + 11.0.0-{{versionSuffix}} + browser-wasm;%(RuntimePackRuntimeIdentifiers) + + + 11.0.0-{{versionSuffix}} + + """; + } + UpdateProjectFile(projectFilePath, runAnalyzers, extraProperties, extraItems, insertAtEnd); return new ProjectInfo(asset.Name, projectFilePath, logPath, nugetDir); } diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index 812ad3661831bd..478c530b217ec7 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -11,6 +11,7 @@ false + false true false @@ -74,6 +75,11 @@ + + + + + @@ -97,6 +103,7 @@ <_XUnitTraitArg Condition="'$(TestUsingWorkloads)' != 'true'">-trait category=no-workload <_XUnitTraitArg Condition="'$(WasmFingerprintAssets)' == 'false'">-trait category=no-fingerprinting <_XUnitTraitArg Condition="'$(WasmBundlerFriendlyBootConfig)' == 'true'">-trait category=bundler-friendly + <_XUnitTraitArg Condition="'$(RuntimeFlavor)' == 'CoreCLR'">-trait category=$(RuntimeFlavor) diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs b/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs new file mode 100644 index 00000000000000..1670dbdc4aea9b --- /dev/null +++ b/src/mono/wasm/Wasm.Build.Tests/WasmBrowserRunMainOnly.cs @@ -0,0 +1,30 @@ +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"); + var (_, buildOutput) = PublishProject(info, config); + + // ** MicrosoftNetCoreAppRuntimePackDir : '....microsoft.netcore.app.runtime.browser-wasm\11.0.0-dev' + Assert.Contains("microsoft.netcore.app.runtime.browser-wasm", buildOutput); + + var result = await RunForPublishWithWebServer(new BrowserRunOptions( + Configuration: config + )); + + Assert.Collection( + result.TestOutput, + m => Assert.Equal("Hello from WasmBrowserRunMainOnly!", m) + ); + } +} diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs index 487b08a6a56db6..93cb9af858aa01 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs @@ -15,11 +15,12 @@ namespace Wasm.Build.Tests; public class WasmSdkBasedProjectProvider : ProjectProviderBase { - private readonly string _defaultTargetFramework; + public string DefaultTargetFramework { get; } + public WasmSdkBasedProjectProvider(ITestOutputHelper _testOutput, string defaultTargetFramework, string? _projectDir = null) : base(_testOutput, _projectDir) { - _defaultTargetFramework = defaultTargetFramework; + DefaultTargetFramework = defaultTargetFramework; } protected override string BundleDirName { get { return "wwwroot"; } } @@ -96,7 +97,7 @@ public NativeFilesType GetExpectedFileType(Configuration config, bool isAOT, boo public void AssertBundle(Configuration config, MSBuildOptions buildOptions, bool isUsingWorkloads, bool? isNativeBuild = null, bool? wasmFingerprintDotnetJs = null) { string frameworkDir = string.IsNullOrEmpty(buildOptions.NonDefaultFrameworkDir) ? - GetBinFrameworkDir(config, buildOptions.IsPublish, _defaultTargetFramework) : + GetBinFrameworkDir(config, buildOptions.IsPublish, DefaultTargetFramework) : buildOptions.NonDefaultFrameworkDir; AssertBundle(new AssertBundleOptions( @@ -181,7 +182,7 @@ public void AssertWasmSdkBundle(Configuration config, MSBuildOptions buildOption if (isUsingWorkloads && buildOutput is not null) { // In no-workload case, the path would be from a restored nuget - ProjectProviderBase.AssertRuntimePackPath(buildOutput, buildOptions.TargetFramework ?? _defaultTargetFramework, buildOptions.RuntimeType); + ProjectProviderBase.AssertRuntimePackPath(buildOutput, buildOptions.TargetFramework ?? DefaultTargetFramework, buildOptions.RuntimeType); } AssertBundle(config, buildOptions, isUsingWorkloads, isNativeBuild, wasmFingerprintDotnetJs); } @@ -191,9 +192,9 @@ public BuildPaths GetBuildPaths(Configuration configuration, bool forPublish, st projectDir ??= ProjectDir!; Assert.NotNull(projectDir); string configStr = configuration.ToString(); - string objDir = Path.Combine(projectDir, "obj", configStr, _defaultTargetFramework); - string binDir = Path.Combine(projectDir, "bin", configStr, _defaultTargetFramework); - string binFrameworkDir = GetBinFrameworkDir(configuration, forPublish, _defaultTargetFramework); + string objDir = Path.Combine(projectDir, "obj", configStr, DefaultTargetFramework); + string binDir = Path.Combine(projectDir, "bin", configStr, DefaultTargetFramework); + string binFrameworkDir = GetBinFrameworkDir(configuration, forPublish, DefaultTargetFramework); string objWasmDir = Path.Combine(objDir, "wasm", forPublish ? "for-publish" : "for-build"); // for build: we should take from runtime pack? diff --git a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd index 608b2c6c1ea37e..0fe961d7e8199e 100644 --- a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd +++ b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd @@ -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% diff --git a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh index cee1769b006639..9cac0dd1442ed3 100644 --- a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh +++ b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh @@ -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 diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs new file mode 100644 index 00000000000000..e258162d095c3f --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Program.cs @@ -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. + +using System.Threading.Tasks; + +class Program +{ + static async Task Main(string[] args) + { + TestOutput.WriteLine("Hello from WasmBrowserRunMainOnly!"); + await Task.Delay(1); + return 0; + } +} \ No newline at end of file diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Properties/AssemblyInfo.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000000..9ad9b578f20649 --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/Properties/AssemblyInfo.cs @@ -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")] diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs new file mode 100644 index 00000000000000..5755b753b5e492 --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/TestOutput.cs @@ -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); + } +} diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj new file mode 100644 index 00000000000000..9951d602d915af --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj @@ -0,0 +1,11 @@ + + + net11.0 + true + true + + + + + + diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/index.html b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/index.html new file mode 100644 index 00000000000000..41fdfc8a46fd1d --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/index.html @@ -0,0 +1,18 @@ + + + + + + + WasmBrowserRunMainOnly + + + + + + + + + + + diff --git a/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js new file mode 100644 index 00000000000000..f30a0c34caff55 --- /dev/null +++ b/src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js @@ -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"); +} \ No newline at end of file diff --git a/src/native/corehost/browserhost/host/host.ts b/src/native/corehost/browserhost/host/host.ts index 689f960ba903e5..9cad2530bda27c 100644 --- a/src/native/corehost/browserhost/host/host.ts +++ b/src/native/corehost/browserhost/host/host.ts @@ -105,6 +105,10 @@ export async function runMain(mainAssemblyName?: string, args?: string[]): Promi if (!mainAssemblyName) { mainAssemblyName = config.mainAssemblyName!; } + // TODO-WASM: Difference in boot config generator + if (!mainAssemblyName.endsWith(".dll")) { + mainAssemblyName += ".dll"; + } const mainAssemblyNamePtr = dotnetBrowserUtilsExports.stringToUTF8Ptr(mainAssemblyName) as any; if (!args) { diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index 8b20592f5fd6f8..d1762eb9a9a0a5 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -12,6 +12,8 @@ GenerateRuntimeVersionFile $(BuildCoreHostDependsOn);InitializeSourceControlInformationFromSourceControlManager $(BuildCoreHostDependsOn);GenerateEmccExports;ResolveRuntimeFilesFromLocalBuild + BuildCoreHostOnWindows + BuildCoreHostOnUnix $(ArtifactsObjDir)$(TargetRid).$(Configuration)\ $(ArtifactsObjDir)_version.h @@ -169,6 +171,25 @@ + + + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)package.json" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)dotnet.d.ts" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.map" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.js" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.a" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.dat" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)libBrowserHost.a" /> + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.js" /> + + <_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.wasm" /> + + + + + diff --git a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs index c5869e14ed77bd..0dbe5e23f6a3c3 100644 --- a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs +++ b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs @@ -18,6 +18,12 @@ public class AssetsComputingHelper "Microsoft.NETCore.App.Runtime.Mono.multithread.browser-wasm", }; + private static readonly string[] coreclrPackageIds = new[] + { + "Microsoft.NETCore.App.Runtime.browser-wasm", + "Microsoft.NETCore.App.Runtime.multithread.browser-wasm", + }; + private static readonly string[] dotnetJsSingleThreadNames = new[] { "dotnet", @@ -52,7 +58,7 @@ public static bool ShouldFilterCandidate( var extension = candidate.GetMetadata("Extension"); var fileName = candidate.GetMetadata("FileName"); var assetType = candidate.GetMetadata("AssetType"); - bool fromMonoPackage = IsFromMonoPackage(candidate); + bool fromMonoPackage = IsFromRuntimePack(candidate); // A similar logic is in ReadWasmNativeAssetsFromFileSystem target for RuntimeTests reason = extension switch @@ -96,10 +102,10 @@ bool IsDefaultIcuMode() => string.IsNullOrEmpty(customIcuCandidateFilename); } - private static bool IsFromMonoPackage(ITaskItem candidate) + private static bool IsFromRuntimePack(ITaskItem candidate) { string packageId = candidate.GetMetadata("NuGetPackageId"); - return monoPackageIds.Contains(packageId, StringComparer.Ordinal); + return monoPackageIds.Contains(packageId, StringComparer.Ordinal) || coreclrPackageIds.Contains(packageId, StringComparer.Ordinal); } public static string GetCandidateRelativePath(ITaskItem candidate, bool fingerprintAssets, bool fingerprintDotNetJs)