In a .NET 10 project file, what does Sdk="Microsoft.NET.Sdk.Web" give a project that plain Microsoft.NET.Sdk does not?
answer
- one attribute, several SDKs imported
- implicit FrameworkReference
- Microsoft.AspNetCore.App shared framework
- OutputType Exe, ServerGarbageCollection true
- web.config written on publish
basics
~10 sMicrosoft.NET.Sdk.Web adds an implicit FrameworkReference to the Microsoft.AspNetCore.App shared framework, imports the Razor and Publish SDKs, makes the project an executable with server GC, and adds ASP.NET Core implicit usings and analyzers.
solid answer
~40 s`Microsoft.NET.Sdk.Web` is a wrapper SDK: it imports `Microsoft.NET.Sdk`, then `Microsoft.NET.Sdk.Razor`, `Microsoft.NET.Sdk.Web.ProjectSystem` and `Microsoft.NET.Sdk.Publish`. The important line is an implicit `<FrameworkReference Include="Microsoft.AspNetCore.App" />`, so all of ASP.NET Core's own assemblies come from the shared framework installed with the runtime, not from NuGet. It also sets `OutputType` to `Exe`, `ServerGarbageCollection` to `true` and `IsPackable` to `false`, adds the ASP.NET Core analyzers and nine extra implicit usings, keeps launch-settings and publish-profile files out of build and publish output, and on `dotnet publish` writes a `web.config` for IIS unless `IsTransformWebConfigDisabled` is set. Packages outside the shared framework — `Microsoft.AspNetCore.OpenApi`, `Microsoft.AspNetCore.Authentication.JwtBearer`, EF Core — are still `PackageReference`s.
code
xml · 14 lines<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.12" />
</ItemGroup>
</Project>go deeper
Recall that the Web SDK brings the Microsoft.AspNetCore.App shared framework, so ASP.NET Core itself needs no NuGet package, while add-ons such as OpenAPI still do.
Explain the four imported SDKs, the implicit FrameworkReference, the Exe and server GC defaults, and the extra implicit usings.
Diagnose project-file mistakes: a leftover Microsoft.AspNetCore.App package, a library on the Web SDK, an unwanted web.config in a container build.
Decide what belongs in a shared Directory.Build.props versus each web project, and how runtime-installed frameworks shape image and patching strategy.
## One attribute, four SDKs The first line of every web template's project file is `<Project Sdk="Microsoft.NET.Sdk.Web">`. An **MSBuild SDK** is a bundle of `.props` and `.targets` files imported before and after the project's own content; the `Sdk` attribute picks the bundle. The Web SDK is a composition: its `Sdk.props` imports, in order, 1. `Microsoft.NET.Sdk` — the ordinary .NET build: compile, restore, default item globs, the base implicit usings; 2. `Microsoft.NET.Sdk.Razor` — compilation of `.cshtml` and `.razor` files and static web assets; 3. `Microsoft.NET.Sdk.Web.ProjectSystem` — web-project defaults and tooling-file handling; 4. `Microsoft.NET.Sdk.Publish` — the publish pipeline, including `web.config` generation. So a web project is a normal .NET project with three more layers, which is why `dotnet build`, `dotnet test` and `dotnet publish` behave the same way on it. ## The shared framework reference The single most important thing the Web SDK adds is ```xml <FrameworkReference Include="Microsoft.AspNetCore.App" IsImplicitlyDefined="true" /> ``` `Microsoft.AspNetCore.App` is the **ASP.NET Core shared framework**: the set of assemblies (Kestrel, routing, MVC, Razor Pages, authentication handlers, Data Protection, SignalR's server, and the `Microsoft.Extensions.*` libraries they need) installed with the ASP.NET Core runtime. A **framework reference** compiles against that installed framework instead of restoring NuGet packages, and at run time the app loads it from the machine or container image. Since .NET Core 3.0, many ASP.NET Core assemblies are no longer published to NuGet as packages at all — in the source, a project such as `Microsoft.AspNetCore.Mvc.Core` is marked `IsAspNetCoreApp` and `IsPackable` false. What the shared framework does **not** contain still arrives as packages: - `Microsoft.AspNetCore.OpenApi` (the template's only package reference); - authentication handlers such as `Microsoft.AspNetCore.Authentication.JwtBearer` and `Microsoft.AspNetCore.Authentication.OpenIdConnect`; - `Microsoft.AspNetCore.Identity.EntityFrameworkCore`, `Microsoft.AspNetCore.Identity.UI` and EF Core itself; - test helpers such as `Microsoft.AspNetCore.Mvc.Testing`. ## The project defaults it sets | Property or item | Value under the Web SDK | Effect | |---|---|---| | `OutputType` | `Exe` | The project builds an application with an entry point | | `ServerGarbageCollection` | `true` (unless set) | The app runs with server GC | | `IsPackable` | `false` (unless set) | `dotnet pack` warns instead of producing a package | | `DebugType` | `full` (unless set) | Full debug symbols | | launch-settings and `PublishProfiles` files | `None` items, never copied | Local tooling files stay out of build and publish output | | ASP.NET Core analyzers | added implicitly | Diagnostics for routing, Minimal APIs and MVC usage | With `ImplicitUsings` enabled the Web SDK also adds nine namespaces on top of the base SDK's seven, among them `Microsoft.AspNetCore.Builder`, `Microsoft.AspNetCore.Http` and `Microsoft.Extensions.DependencyInjection` — that is why a template's `Program.cs` needs no `using` lines. ## What it does on publish The Publish SDK transforms or creates a `web.config` in the publish folder when the project is an ASP.NET Core project, so an IIS site can launch the app through the ASP.NET Core Module. Setting `<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>` turns that off — useful when the app only ever runs in a Linux container and a stray `web.config` confuses reviewers. ## Common mistakes - **Adding `PackageReference Include="Microsoft.AspNetCore.App"`.** That is the 2.x metapackage habit; the .NET SDK warns with NETSDK1080 and replaces it with the framework reference. - **Expecting MVC types without a `using`.** `Microsoft.AspNetCore.Mvc` is not one of the implicit usings, so a controller file still needs `using Microsoft.AspNetCore.Mvc;`. - **Using the Web SDK for a class library.** `OutputType` becomes `Exe`, so a library with no entry point fails to build; a library uses `Microsoft.NET.Sdk` plus an explicit framework reference instead. ## Checking what the SDK actually set Because these defaults are MSBuild properties, they can be inspected rather than guessed. `dotnet msbuild -getProperty:OutputType -getProperty:ServerGarbageCollection` prints the evaluated values for the project, and the same switch works for `IsPackable` or `TargetFramework`. Any of them can be overridden in the project file — for example `<ServerGarbageCollection>false</ServerGarbageCollection>` turns the server GC default back off. In short, the `Sdk` attribute is the difference between "a .NET program" and "an ASP.NET Core application": it decides which framework the app runs on, how it is built and what `dotnet publish` produces.
- Why do Microsoft.AspNetCore.OpenApi and Microsoft.AspNetCore.Authentication.JwtBearer need PackageReferences in a Web SDK project?They are not part of the `Microsoft.AspNetCore.App` shared framework. They ship as NuGet packages so they can carry their own dependencies (Microsoft.OpenApi, Microsoft.IdentityModel) and so apps that do not use them do not carry them.
- What happens if a .NET 10 project still has PackageReference Include="Microsoft.AspNetCore.App" from a 2.x upgrade?The SDK raises warning NETSDK1080, removes the package reference and uses a `FrameworkReference` to `Microsoft.AspNetCore.App` instead. Delete the line; under `Microsoft.NET.Sdk.Web` the framework reference is already implicit.
- Microsoft.NET.Sdk.Web restores ASP.NET Core from NuGet like any other package
- You must add PackageReference Microsoft.AspNetCore.App to use ASP.NET Core in .NET 10
- JwtBearer authentication is in the shared framework, so no package is needed
- The Web SDK is fine for a class library because it only adds usings
- The Web SDK writes web.config into the project folder on every build