Fix WASM workload detection for non-Blazor/WasmSdk Exe projects#52677
Fix WASM workload detection for non-Blazor/WasmSdk Exe projects#52677DrewScoggins wants to merge 2 commits intodotnet:mainfrom
Conversation
This fixes an issue where BenchmarkDotNet-generated WASM benchmark projects stopped working after commit 34e2468 removed the _UsingBlazorOrWasmSdk condition from _WasmNativeWorkloadNeeded. The change in that commit was intended to allow library projects with RuntimeIdentifier=browser-wasm to build without requiring the WASM workload (per dotnet/runtime#122607). However, the change was too broad - it affected ALL non-Blazor/WasmSdk projects, including Exe projects that need the workload for runtime pack resolution. This fix adds back the workload requirement specifically for Exe projects that don't use Blazor/WasmSdk, while preserving the library-mode-without-workload behavior. Changes: - WorkloadManifest.targets.in: Added condition to set _WasmNativeWorkloadNeeded for Exe projects without BlazorOrWasmSdk - Added regression tests to verify: - Exe projects trigger workload usage (UsingBrowserRuntimeWorkload=true) - Library projects don't force workload usage - Runtime pack version is available when workload is used - Added test asset WasmConsoleApp for the test scenarios Fixes the 'MicrosoftNetCoreAppRuntimePackDir is empty' error in WASM benchmarks.
|
This fix came out of discussion with Copilot. Let me know if the tests don't match up with what y'all do in this repo. |
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where WASM workload detection was broken for non-Blazor/WasmSdk Exe projects (such as those generated by BenchmarkDotNet). The previous change that allowed library projects targeting browser-wasm to build without the workload inadvertently affected all non-Blazor/WasmSdk projects, including Exe projects that require the workload for runtime pack resolution.
Changes:
- Added a condition to require the WASM workload for Exe projects that don't use Blazor/WasmSdk
- Added comprehensive test coverage to verify workload behavior for both Exe and library projects
- Added test asset files for WasmConsoleApp (though not used by the automated tests)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| WorkloadManifest.targets.in | Adds condition to set _WasmNativeWorkloadNeeded=true for Exe projects without Blazor/WasmSdk, preserving library-mode-without-workload behavior |
| WasmWorkloadDetectionTests.cs | New test class with three tests covering Exe workload requirement, library non-requirement, and runtime pack version availability |
| WasmConsoleApp/WasmConsoleApp.csproj | Test asset project file for WASM console app (not used in automated tests) |
| WasmConsoleApp/Program.cs | Test asset source file with simple console output (not used in automated tests) |
| WasmConsoleApp/main.js | Test asset JavaScript entry point (not used in automated tests, contains reference to non-existent Greeting method) |
| { | ||
| /// <summary> | ||
| /// Tests for WASM workload detection with projects using Microsoft.NET.Sdk (not Blazor/WebAssembly SDK). | ||
| /// These tests verify the fix for https://github.com/dotnet/sdk/issues/XXXXX where BenchmarkDotNet |
There was a problem hiding this comment.
The placeholder issue number "XXXXX" should be replaced with the actual GitHub issue number.
| /// These tests verify the fix for https://github.com/dotnet/sdk/issues/XXXXX where BenchmarkDotNet | |
| /// These tests verify the fix for a bug where BenchmarkDotNet |
|
Just to be clear, this is currently blocking our ability to collect performance results on WASM. |
| <!-- Exe projects targeting browser-wasm without Blazor/WasmSdk need the workload for runtime pack resolution. | ||
| This ensures tools like BenchmarkDotNet that generate WASM console apps work correctly. | ||
| Library projects can build without the workload (they don't need AppBundle generation). --> | ||
| <_WasmNativeWorkloadNeeded Condition="'$(_UsingBlazorOrWasmSdk)' != 'true' and '$(OutputType)' == 'Exe'">true</_WasmNativeWorkloadNeeded> |
There was a problem hiding this comment.
Please add and '$(_WasmNativeWorkloadNeeded)' == ''
|
@maraf has this in progress dotnet/runtime#122607 I wonder if it's the solution for the same or similar problem |
|
Also much more localized solution could be to add Edit: hmm, it's already there |
|
I wonder if that file is ever imported ... |
|
|
So far I think this is about missing runtime pack.
Probably nuget of the right version is not yet in the right feed ? |
is this just becase UseMonoRuntime isn't set? |
The problem is that dotnet/perf doesn't use WasmSDK and we don't have the former bundler anymore. WIP in dotnet/performance#5101 |


This fixes an issue where BenchmarkDotNet-generated WASM benchmark projects stopped working after commit 34e2468 removed the _UsingBlazorOrWasmSdk condition from _WasmNativeWorkloadNeeded.
The change in that commit was intended to allow library projects with RuntimeIdentifier=browser-wasm to build without requiring the WASM workload (per dotnet/runtime#122607). However, the change was too broad - it affected ALL non-Blazor/WasmSdk projects, including Exe projects that need the workload for runtime pack resolution.
This fix adds back the workload requirement specifically for Exe projects that don't use Blazor/WasmSdk, while preserving the library-mode-without-workload behavior.
Changes:
Fixes the 'MicrosoftNetCoreAppRuntimePackDir is empty' error in WASM benchmarks.