Add new webworker template project#65037
Merged
ilonatommy merged 50 commits intodotnet:mainfrom Feb 6, 2026
Merged
Conversation
The webworker item template generates a .csproj file into the content/ folder during build. NuGet was discovering and trying to restore this generated project, but it failed because: 1. The package Microsoft.AspNetCore.Components.WebAssembly version 11.0.0-ci doesn't exist in NuGet feeds (it's built in this repo) 2. The generated project was being evaluated before the package was built Fix: Add Web.ItemTemplates/content/**/*.proj to ProjectToExclude in eng/Build.props, matching the existing exclusion for Web.ProjectTemplates. Also simplified Directory.Build.props in the content folder to remove the sources.props import which is no longer needed since the projects are excluded from build.
The ByteOrderMarkTest requires all .razor files in templates to have UTF-8 BOM (Byte Order Mark) for proper encoding detection.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new dotnet new webworker template that enables WebWorker support for Blazor WebAssembly applications, allowing compute-intensive .NET code to run off the main UI thread for improved responsiveness. The template provides both an infrastructure-only mode (--empty) and a full mode with demo code showcasing GitHub API integration.
Changes:
- New WebWorker item template with client library, JavaScript worker infrastructure, and optional demo files
- Integration with BlazorWeb template to optionally include WorkerClient project
- Comprehensive README documentation and localization for 13 languages
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/.template.config/template.json | Template configuration defining parameters, symbols, and post-actions |
| src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/WebWorkerTemplate.WorkerClient/WorkerClient.cs | C# client for communicating with WebWorker via JSInterop |
| src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/WebWorkerTemplate.WorkerClient/wwwroot/worker.js | JavaScript WebWorker entry point for loading .NET runtime |
| src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/WebWorkerTemplate.WorkerClient/wwwroot/worker-client.js | JavaScript client for managing worker lifecycle and message passing |
| src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/Worker/GitHubWorker.cs | Demo worker class showing GitHub API data processing |
| src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/Pages/WebWorkerDemo.razor.cs | Demo Blazor page comparing WebWorker vs UI thread performance |
| src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/Models/GitHubModels.cs | Model classes for GitHub API responses |
| src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/template.json | Updated to reference WorkerClient project |
| src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1.sln | Solution file with conditional WorkerClient project inclusion |
| src/ProjectTemplates/Web.ItemTemplates/Microsoft.DotNet.Web.ItemTemplates.csproj | Build configuration for generating WorkerClient.csproj |
| eng/Build.props | Updated to exclude template content projects from build |
| src/ProjectTemplates/Web.ItemTemplates/.gitignore | Ignore generated .csproj files |
| Multiple localization files | Translated template descriptions for 13 languages |
src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/Worker/GitHubWorker.cs
Outdated
Show resolved
Hide resolved
...rojectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/template.json
Outdated
Show resolved
Hide resolved
...Templates/Web.ItemTemplates/content/WebWorker/WebWorkerTemplate.WorkerClient/WorkerClient.cs
Outdated
Show resolved
Hide resolved
...Templates/Web.ItemTemplates/content/WebWorker/WebWorkerTemplate.WorkerClient/WorkerClient.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/Pages/WebWorkerDemo.razor.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1.sln
Outdated
Show resolved
Hide resolved
...rojectTemplates/Web.ItemTemplates/content/WebWorker/WebWorkerTemplate.WorkerClient/README.md
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Web.ItemTemplates/content/WebWorker/Pages/WebWorkerDemo.razor.cs
Outdated
Show resolved
Hide resolved
...Templates/Web.ItemTemplates/content/WebWorker/WebWorkerTemplate.WorkerClient/WorkerClient.cs
Outdated
Show resolved
Hide resolved
danroth27
reviewed
Jan 28, 2026
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/wwwroot/dotnet-web-worker.js
Show resolved
Hide resolved
danroth27
reviewed
Jan 28, 2026
...tTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/wwwroot/dotnet-web-worker-client.js
Show resolved
Hide resolved
danroth27
reviewed
Jan 28, 2026
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/WorkerClient.cs
Outdated
Show resolved
Hide resolved
…harp/WorkerClient.cs Co-authored-by: Daniel Roth <daroth@microsoft.com>
danroth27
reviewed
Jan 28, 2026
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/WebWorkerClient.cs
Show resolved
Hide resolved
danroth27
reviewed
Jan 28, 2026
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/WorkerClient.cs
Outdated
Show resolved
Hide resolved
pavelsavara
reviewed
Jan 28, 2026
src/ProjectTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/WebWorkerClient.cs
Show resolved
Hide resolved
javiercn
reviewed
Jan 29, 2026
src/ProjectTemplates/test/Templates.Blazor.Tests/WebWorkerTemplateTest.cs
Outdated
Show resolved
Hide resolved
javiercn
reviewed
Jan 29, 2026
...tTemplates/Web.ProjectTemplates/content/WebWorker-CSharp/wwwroot/dotnet-web-worker-client.js
Outdated
Show resolved
Hide resolved
javiercn
approved these changes
Feb 6, 2026
Member
javiercn
left a comment
There was a problem hiding this comment.
Looks good. Let's get it in for now and we'll get to play with it and refine it if necessary
4 tasks
akoeplinger
added a commit
to dotnet/sdk
that referenced
this pull request
Feb 15, 2026
Add .NET entry to approval baselines after dotnet/aspnetcore#65037 introduced the webworker template.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Worker Class Library template (
dotnet new webworker)Summary
Adds a new .NET Web Worker project template that provides infrastructure for running .NET code in a WebWorker, keeping your WebAssembly UI responsive during heavy computations.
Background
Blazor WASM applications with heavy computing had to rely on server requests. Computing on the UI thread interfered with UI rendering and affected UX. In .NET 10 we added an article with a sample application to make offloading heavy work to a WebWorker easier. In .NET 11 we decided to add official template support. This PR adds a project template that enables running .NET code in a WebWorker.
Template Output
Usage
Methods
Fixes dotnet/runtime#95452