/errors/dotnet-cli/netsdk1045-current-sdk-does-not-support-targeting
error NETSDK1045: The current .NET SDK does not support targeting .NET X
- 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:
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
dotnet --version # SDK selected for the current directory (honours global.json)
dotnet --list-sdks # all installed SDKsIf dotnet --version is older than the newest entry in --list-sdks, a global.json in the directory or a parent is pinning it:
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestFeature"
}
}Fixes
| Situation | Fix |
|---|---|
| SDK not installed | Install the matching SDK from dot.net, or with your package manager |
| global.json pins an old SDK | Update "version", or use "rollForward": "latestMajor" if any newer SDK is fine |
| GitHub Actions | actions/setup-dotnet with dotnet-version set to the target, e.g. 10.0.x |
| Docker build | Use an SDK base image of the same version (mcr.microsoft.com/dotnet/sdk:10.0) |
| Visual Studio | Update Visual Studio; each release bundles a specific SDK band |