You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upgrade to .NET 10, Aspire 13, and System.CommandLine 2.0 (#794)
### Summary & Motivation
Upgrade the codebase to .NET 10 and adopt new C# 14 language features.
- Update all projects to target .NET 10.
- Update to Aspire 13 and use `Aspire.Hosting.JavaScript` over the
deprecated `Aspire.Hosting.NodeJS`.
- Update Docker images to use secure chiseled base images:
`mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled-extra` for projects
using Entity Framework, and
`mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled` for AppGateway.
- Upgrade `System.CommandLine` to 2.0.0 and migrate from
`NamingConventionBinder` to the new `SetAction` API.
- Convert extension methods to C# 14 extension members syntax using
`extension(Type param)`.
- Update properties with backing fields to use the new `field` keyword.
- Remove `params` keyword from extension methods to avoid Roslyn
compiler errors
([dotnet/roslyn#80024](dotnet/roslyn#80024)).
### Downstream projects
Downstream projects must make the following changes to align with this
upgrade:
1. **Update all `*.csproj` files** to target .NET 10:
```diff
- <TargetFramework>net9.0</TargetFramework>
+ <TargetFramework>net10.0</TargetFramework>
```
2. **Update all WebApp `.esproj` files** (e.g.,
`application/your-self-contained-system/WebApp/YourSystem.WebApp.esproj`):
```diff
- <TargetFrameworkMoniker>net9.0</TargetFrameworkMoniker>
+ <TargetFrameworkMoniker>net10.0</TargetFrameworkMoniker>
```
3. **Update Dockerfiles** to use secure chiseled base images:
- For API and Workers projects (that use Entity Framework):
```diff
- FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine
- RUN apk add --no-cache icu-libs
- ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
+ FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled-extra
```
4. **Remove WebApp `.esproj` references from AppHost** in
`application/AppHost/AppHost.csproj`:
```diff
- <ProjectReference
Include="..\your-self-contained-system\WebApp\YourSystem.WebApp.esproj"/>
```
With `Aspire.Hosting.JavaScript` using the new `AddJavaScriptApp()` over
`AddNpmApp()` eliminates the need for `.esproj` project references in
AppHost.
5. **Update
`application/your-self-contained-system/Tests/EndpointBaseTest.cs`** to
use the new `field` keyword for auto-implemented properties with backing
fields:
```diff
- private ServiceProvider? _provider;
- protected ServiceProvider Provider => _provider ??=
Services.BuildServiceProvider();
+ protected ServiceProvider Provider => field ??=
Services.BuildServiceProvider();
```
Also update the reference in `EndpointBaseTest` constructor:
```diff
- using var serviceScope = Provider.CreateScope();
+ using var serviceScope = Provider!.CreateScope();
```
6. **Fix extension method calls in SharedKernel** that had the `params`
keyword removed due to [Roslyn issue
#80024](dotnet/roslyn#80024):
- Methods like `AddApiServices()`, `AddSharedInfrastructure()`,
`AddWorkerServices()`, and similar extension methods in SharedKernel no
longer use `params` for their assembly parameters.
- Update calls to pass arrays explicitly:
`services.AddApiServices([assembly1, assembly2])` instead of
`services.AddApiServices(assembly1, assembly2)`.
- Example from `application/your-self-contained-system/Api/Program.cs`:
```diff
- builder.Services.AddApiServices(Assembly.GetExecutingAssembly(),
typeof(Configuration).Assembly);
+ builder.Services.AddApiServices([Assembly.GetExecutingAssembly(),
typeof(Configuration).Assembly]);
```
7. **If you have a custom developer CLI**, update any custom commands to
use System.CommandLine 2.0.0 syntax:
- Replace `System.CommandLine.NamingConventionBinder` with
`System.CommandLine.Invocation`.
- Replace `Handler = CommandHandler.Create<...>(Execute)` with
`this.SetAction(parseResult => Execute(...))`.
- Update option definitions from inline construction to explicit
`Options.Add()` calls.
- See `developer-cli/Commands/CheckCommand.cs` for a complete example.
8. **Optional: Adopt C# 14 features:**
- Convert extension methods to use the new `extension(Type param)`
syntax (see
`application/shared-kernel/SharedKernel/ApiResults/ApiResultExtensions.cs`
for examples).
- Update properties with explicit backing fields to use the new `field`
keyword (see the `EndpointBaseTest.cs` change in step 5).
9. **Developers need to install .NET 10 SDK.** Aspire's AppHost
automatically handles SSL certificate creation and management when
running the application locally. If you encounter certificate-related
errors after upgrading, the AppHost will regenerate certificates
automatically on the next run.
### Checklist
- [x] I have added tests, or done manual regression tests
- [x] I have updated the documentation, if necessary
- [Workers](mdc:application/back-office/Workers): A .NET Console job.
54
54
- [Tests](mdc:application/back-office/Tests): xUnit tests for backend.
55
-
- [AppHost](mdc:application/AppHost): .NET Aspire project for orchestrating SCSs and Docker containers. Never run directly—typically running in watch mode.
56
-
- [AppGateway](mdc:application/AppGateway): Main entry point using .NET YARP as reverse proxy for all SCSs.
55
+
- [AppHost](mdc:application/AppHost): Aspire project for orchestrating SCSs and Docker containers. Never run directly—typically running in watch mode.
56
+
- [AppGateway](mdc:application/AppGateway): Main entry point using YARP as reverse proxy for all SCSs.
57
57
- [shared-kernel](mdc:application/shared-kernel): Reusable .NET backend shared by all SCSs.
58
58
- [shared-webapp](mdc:application/shared-webapp): Reusable frontend shared by all SCSs.
59
59
- [cloud-infrastructure](mdc:cloud-infrastructure): Bash and Azure Bicep scripts (IaC).
-[Workers](/application/back-office/Workers): A .NET Console job.
54
54
-[Tests](/application/back-office/Tests): xUnit tests for backend.
55
-
-[AppHost](/application/AppHost): .NET Aspire project for orchestrating SCSs and Docker containers. Never run directly—typically running in watch mode.
56
-
-[AppGateway](/application/AppGateway): Main entry point using .NET YARP as reverse proxy for all SCSs.
55
+
-[AppHost](/application/AppHost): Aspire project for orchestrating SCSs and Docker containers. Never run directly—typically running in watch mode.
56
+
-[AppGateway](/application/AppGateway): Main entry point using YARP as reverse proxy for all SCSs.
57
57
-[shared-kernel](/application/shared-kernel): Reusable .NET backend shared by all SCSs.
58
58
-[shared-webapp](/application/shared-webapp): Reusable frontend shared by all SCSs.
59
59
-[cloud-infrastructure](/cloud-infrastructure): Bash and Azure Bicep scripts (IaC).
Copy file name to clipboardExpand all lines: README.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Built to demonstrate seamless flow—backend contracts feed a fully-typed React
27
27
28
28
## What's inside
29
29
30
-
***Backend** - .NET 9 and C# adhering to the principles of vertical slice architecture, DDD, CQRS, and clean code
30
+
***Backend** - .NET 10 and C# 14 adhering to the principles of vertical slice architecture, DDD, CQRS, and clean code
31
31
***Frontend** – React 19, TypeScript, TanStack Router & Query, React Aria for accessible and UI
32
32
***CI/CD** - GitHub actions for fast passwordless deployments of docker containers and infrastructure (Bicep)
33
33
***Infrastructure** - Cost efficient and scalable Azure PaaS services like Azure Container Apps, Azure SQL, etc.
@@ -59,7 +59,7 @@ For development, you need .NET, Docker, and Node. And GitHub and Azure CLI for s
59
59
2. From an Administrator PowerShell terminal, use [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) (preinstalled on Windows 11) to install any missing packages:
60
60
61
61
```powershell
62
-
winget install Microsoft.DotNet.SDK.9
62
+
winget install Microsoft.DotNet.SDK.10
63
63
winget install Git.Git
64
64
winget install Docker.DockerDesktop
65
65
winget install OpenJS.NodeJS
@@ -125,10 +125,10 @@ Open a terminal and run the following commands (if not installed):
125
125
sudo apt-get update
126
126
```
127
127
128
-
- Install .NET SDK 9.0, Node, GitHub CLI
128
+
- Install .NET SDK 10.0, Node, GitHub CLI
129
129
130
130
```bash
131
-
sudo apt-get install -y dotnet-sdk-9.0 nodejs gh
131
+
sudo apt-get install -y dotnet-sdk-10.0 nodejs gh
132
132
```
133
133
134
134
- Install Azure CLI
@@ -161,7 +161,7 @@ We recommend you keep the commit history, which serves as a great learning and t
161
161
162
162
## 2. Run the Aspire AppHost to spin up everything on localhost
163
163
164
-
Using .NET Aspire, docker images with SQL Server, Blob Storage emulator, and development mail server will be downloaded and started. No need install anything, or learn complicated commands. Simply run this command, and everything just works 🎉
164
+
Using Aspire, docker images with SQL Server, Blob Storage emulator, and development mail server will be downloaded and started. No need install anything, or learn complicated commands. Simply run this command, and everything just works 🎉
165
165
166
166
```bash
167
167
cd application/AppHost
@@ -205,7 +205,7 @@ PlatformPlatform is a [monorepo](https://en.wikipedia.org/wiki/Monorepo) contain
205
205
├─ .github # Separate GitHub workflows for deploying Infrastructure and app
206
206
├─ .windsurf # Copy of .cursor for Windsurf AI editor (synchronized by CLI)
207
207
├─ application # Contains the application source code
208
-
│ ├─ AppHost #.NET Aspire project starting app and all dependencies in Docker
208
+
│ ├─ AppHost # Aspire project starting app and all dependencies in Docker
209
209
│ ├─ AppGateway # Main entry point for the app using YARP as a reverse proxy
210
210
│ ├─ account-management # Self-contained system with account sign-up, user management, etc.
211
211
│ │ ├─ WebApp # React SPA frontend using TypeScript and React Aria Components
@@ -233,12 +233,12 @@ PlatformPlatform is a [monorepo](https://en.wikipedia.org/wiki/Monorepo) contain
233
233
234
234
# Technologies
235
235
236
-
### .NET 9 Backend With Vertical Sliced Architecture, DDD, CQRS, Minimal API, and Aspire
236
+
### .NET 10 Backend With Vertical Sliced Architecture, DDD, CQRS, Minimal API, and Aspire
237
237
238
238
The backend is built using the most popular, mature, and commonly used technologies in the .NET ecosystem:
239
239
240
-
-[.NET 9](https://dotnet.microsoft.com) and [C# 13](https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp)
241
-
-[.NET Aspire](https://aka.ms/dotnet-aspire)
240
+
-[.NET 10](https://dotnet.microsoft.com) and [C# 14](https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp)
0 commit comments