warning NETSDK1138: The target framework 'net6.0' is out of support and will not receive security updates in the future. The SDK is telling you that the .NET version your project targets has reached the end of its support. The build still works; the fix is to move TargetFramework to a supported version such as net10.0.

Change one line in the .csproj, build, run your tests and fix whatever the newer framework reports. Turning the check off with CheckEolTargetFramework hides the line but leaves the project on a framework that gets no more patches.

The error

  Determining projects to restore...
C:\Program Files\dotnet\sdk\10.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(32,5): warning NETSDK1138: The target framework 'net6.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [...\OldLab\OldLab.csproj]
...
  OldLab -> ...\OldLab\bin\Debug\net6.0\OldLab.dll

Build succeeded.
...
    3 Warning(s)
    0 Error(s)

The project path is shortened and repeated copies of the warning are cut; nothing else was changed.

Why it happens

Each SDK carries a list of target frameworks whose support has ended, in Microsoft.NET.EolTargetFrameworks.targets, the file named in the message. When your TargetFramework is on that list, the SDK prints this warning during restore and again during the build. Nothing is broken: the net6.0 project built, and dotnet run printed Hello, World! because this machine still has the 6.0.36 runtime installed. The warning is about the future. The runtime receives no more security fixes, so a vulnerability found tomorrow stays open in your app.

One detail surprised us. With TreatWarningsAsErrors set to true, both on the command line and in the .csproj, NETSDK1138 stayed a warning and the build still succeeded on SDK 10.0.403. A build that fails on warnings will not stop on this one, so do not rely on CI to catch it.

The fix

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable><TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

</Project>
dotnet build
dotnet run

After the change the build reported 0 warnings and the app ran. In a real project, also raise the versions of Microsoft.* packages that follow the framework (EF Core, ASP.NET Core extensions) to the matching major version, and update any Dockerfile base image tags and the global.json if you have one. Pick the target from the support policy page the message links.

If you must keep building an old target for a while, the documented switch is CheckEolTargetFramework. dotnet build -p:CheckEolTargetFramework=false built the same net6.0 project with 0 warnings. Treat it as a reminder you have silenced, not a fix.

How it was reproduced

A dotnet new console project on .NET SDK 10.0.403 with its TargetFramework changed from net10.0 to net6.0, then dotnet build. Installed runtimes were 6.0.36, 7.0.20, 8.0.33, 9.0.22 and 10.0.14. Retargeting to net10.0 removed the warning.

Frequently asked

What does NETSDK1138 target framework is out of support mean?
The .NET version your project targets has reached end of support and gets no more security updates. The project still builds and runs; the warning asks you to move to a supported version.
How do I fix NETSDK1138 in a .NET 6 project?
Change TargetFramework in the csproj from net6.0 to a supported version such as net10.0, update the Microsoft packages that follow the framework version, then build and run your tests.
How do I hide the NETSDK1138 warning?
Set the MSBuild property CheckEolTargetFramework to false, for example dotnet build -p:CheckEolTargetFramework=false. It only hides the warning; the framework still receives no security fixes.

More decoded errors in the Fixes category. If the newer target then fails because the SDK is missing, see NETSDK1045.