MSBuild "MSB4236: The SDK Microsoft.NET.Sdk was not found"
MSBuild could not locate the Microsoft.NET.Sdk MSBuild SDK that an SDK-style project needs. Usually the build is using a standalone/old MSBuild (or no .NET SDK is on PATH) that has no knowledge of the project SDK.
What this error means
Build fails at the <Project Sdk="Microsoft.NET.Sdk"> line with MSB4236 saying the SDK could not be found. Common when invoking msbuild from Visual Studio Build Tools without the .NET SDK, or when no SDK is installed.
error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.Common causes
No .NET SDK on PATH
SDK-style projects resolve Microsoft.NET.Sdk from an installed .NET SDK. If none is installed or dotnet is not on PATH, MSBuild cannot find it.
Using a standalone/old MSBuild
Invoking msbuild.exe from a Build Tools install without the .NET SDK component (or an MSBuild too old to know the SDK) fails to resolve the project SDK.
How to fix it
Build with the .NET SDK
Use dotnet build, which carries the matching MSBuild and SDK resolver.
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- run: dotnet build -c ReleaseInstall the SDK component for MSBuild
- If you must use
msbuild, install the .NET SDK so its SDK resolver is available. - On Windows Build Tools, add the ".NET SDK" workload component.
- Confirm with
dotnet --list-sdksthat an SDK is present before building.
How to prevent it
- Prefer
dotnet buildover standalonemsbuildfor SDK-style projects in CI. - Ensure a .NET SDK is installed and on PATH on the runner.
- Pin the SDK version so the project SDK always resolves.