Skip to content

/errors/dotnet-cli/netsdk1045-current-sdk-does-not-support-targeting

error NETSDK1045: The current .NET SDK does not support targeting .NET X

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · 10.0.401updated
tool
.NET CLI
exit code
1
versions
.NET SDK 5 – 10
os
any

error NETSDK1045: The current .NET SDK does not support targeting .NET X. Either target .NET Y or lower, or use a version of the .NET SDK that supports .NET X. means the SDK running the build is older than the TargetFramework in the project file. Each SDK can build for its own .NET version and older ones only. Install the SDK for that .NET version, or check that global.json does not pin an older one.

Reproduce it

A project that targets a version no SDK supports (net99.0) shows the exact message:

bash
mkdir app && cd app
cat > app.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net99.0</TargetFramework>
  </PropertyGroup>
</Project>
EOF
echo 'System.Console.WriteLine("hi");' > Program.cs
dotnet build -nologo 2>&1 | grep -o 'error NETSDK1045: [^[]*' | sort -u
exit ${PIPESTATUS[0]}

Output · exit 1

error NETSDK1045: The current .NET SDK does not support targeting .NET 99.0.  Either target .NET 10.0 or lower, or use a version of the .NET SDK that supports .NET 99.0. Download the .NET SDK from https://aka.ms/dotnet/download

The second sentence names the highest version the running SDK supports ("target .NET 10.0 or lower" for a .NET 10 SDK).

Find which SDK is used

bash
dotnet --version        # SDK selected for the current directory (honours global.json)
dotnet --list-sdks      # all installed SDKs

If dotnet --version is older than the newest entry in --list-sdks, a global.json in the directory or a parent is pinning it:

global.json
{
  "sdk": {
    "version": "10.0.100",
    "rollForward": "latestFeature"
  }
}

Fixes

SituationFix
SDK not installedInstall the matching SDK from dot.net, or with your package manager
global.json pins an old SDKUpdate "version", or use "rollForward": "latestMajor" if any newer SDK is fine
GitHub Actionsactions/setup-dotnet with dotnet-version set to the target, e.g. 10.0.x
Docker buildUse an SDK base image of the same version (mcr.microsoft.com/dotnet/sdk:10.0)
Visual StudioUpdate Visual Studio; each release bundles a specific SDK band

Sources