-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[browser] Use Runtime=NET for build tasks in WebAssembly SDK #123304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…arget layout - Change Microsoft.NET.Sdk.WebAssembly.Pack.Tasks to single-target $(NetCoreAppToolCurrent) - Update GetFilesToPackage to place DLLs/PDBs directly in tools/ (no TFM subfolders) - Remove _WebAssemblySdkTasksTFM property logic from Browser.targets - Add Runtime="NET" attribute to all UsingTask declarations for the tasks Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
|
@copilot There is a build error Fix it by adding |
Single-targeted projects still output to $(OutputPath)$(TargetFramework)\ directory. Update GetFilesToPackage to correctly locate DLLs/PDBs in the TFM subfolder. Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
Fixed in f8ac36d. The GetFilesToPackage target now uses |
|
@copilot Your last change did not fix the issue. There is a build error Fix it by adding |
Update WasmApp.InTree.props and trimmingTests.targets to include $(NetCoreAppToolCurrent) in the tasks assembly path for in-tree builds, matching the single-target output structure. Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
Fixed in 813dae0. The issue was that in-tree build configurations in |
...nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets
Outdated
Show resolved
Hide resolved
|
@copilot Remove all TaskFactory from UsingTask that you changed in the this PR |
TaskFactory is not needed when Runtime="NET" is specified, as MSBuild automatically uses the appropriate factory. Co-authored-by: maraf <10020471+maraf@users.noreply.github.com>
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes the WebAssembly SDK pack tasks to use MSBuild's Runtime="NET" attribute, dropping legacy multi-targeting support and simplifying the NuGet package layout. The change aligns with recent MSBuild improvements for selecting .NET runtime for tasks.
Changes:
- Single-target the Microsoft.NET.Sdk.WebAssembly.Pack.Tasks project to
$(NetCoreAppToolCurrent), removingnet472multi-targeting - Simplify NuGet package layout by placing tasks DLL/PDB directly in
tools/instead oftools/{tfm}/subdirectories - Add
Runtime="NET"to all UsingTask declarations and remove the now-unnecessaryTaskFactoryattribute - Update in-tree build paths to include
$(NetCoreAppToolCurrent)to match the single-target output structure
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj | Single-targets to $(NetCoreAppToolCurrent) and simplifies GetFilesToPackage target to output directly to tools/ |
| src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets | Removes _WebAssemblySdkTasksTFM logic, updates assembly path, and adds Runtime="NET" to UsingTask declarations |
| src/mono/browser/build/WasmApp.InTree.props | Updates _WebAssemblySdkToolsDirectory path to include $(NetCoreAppToolCurrent) for in-tree builds |
| eng/testing/linker/trimmingTests.targets | Updates WasmSdkPackTasksPath to include $(NetCoreAppToolCurrent) for in-tree builds |
Fixes #123155
Tested manually with Visual Studio (2026) Canary
Description
Aligns WebAssembly SDK pack tasks with MSBuild's
Runtime="NET"attribute, dropping legacy multi-targeting for a simpler NuGet package layout.Changes
Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj
$(NetCoreAppToolCurrent)(was multi-targetingnet472)tools/(wastools/{tfm}/)GetFilesToPackagetarget uses$(OutputPath)which automatically includes TFM for single-targeted projectsMicrosoft.NET.Sdk.WebAssembly.Browser.targets
_WebAssemblySdkTasksTFMproperty and MSBuildRuntimeType-based TFM selectiontools/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.dll(wastools/{tfm}/...)Runtime="NET"to UsingTask declarations (withoutTaskFactoryas it's redundant) for:WasmApp.InTree.props
_WebAssemblySdkToolsDirectoryto include$(NetCoreAppToolCurrent)in path for in-tree buildseng/testing/linker/trimmingTests.targets
WasmSdkPackTasksPathto include$(NetCoreAppToolCurrent)in path for in-tree buildsNuGet Package Layout
Before:
After:
The
Runtime="NET"attribute ensures tasks run on .NET Core regardless of MSBuild host. TheTaskFactoryattribute is omitted as MSBuild automatically uses the appropriate factory whenRuntime="NET"is specified. In-tree build configurations are updated to correctly locate the tasks assembly in the single-target output structure (artifacts/bin/.../Release/net11.0/).Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.