How to pin the .NET SDK version with global.json (rollForward explained)
A global.json file tells the dotnet CLI which SDK to use for a repository, so every developer and every CI agent builds with a compatible SDK. This guide shows how to create one, how the SDK finds it, what each rollForward value allows, and the paths, errorMessage and test runner settings added in the .NET 10 SDK.
What global.json controls (and what it does not) From the source
Without a global.json file, the dotnet CLI uses the newest SDK installed on the machine. A global.json file lets you choose which SDK version is used when you run .NET CLI commands such as build, test and publish. Microsoft's documentation applies it to the .NET Core 3.1 SDK and later.
It does not choose the runtime your app runs on. That comes from the TargetFramework in the project file, such as net10.0. A repository can pin SDK 10.0.100 and still build projects that target net8.0, because newer SDKs can target older frameworks.
At a glance · .NET
What global.json controls (and what it does not)Create oneHow the SDK finds the fileThe version property and feature bandsrollForward valuesPrerelease SDKs and the .NET 10 additionsWhat we recommend
Create one From the source
Run dotnet --list-sdks to see what is installed, then create the file in the repository root with the dotnet new template. For example, dotnet new globaljson --sdk-version 8.0.302 --roll-forward latestFeature creates a global.json in the current folder that asks for SDK 8.0.302 or any newer 8.0 feature band and patch.
The resulting file is a small JSON object with an sdk section containing version and rollForward. JavaScript or C# style comments are allowed in the file, which is handy for explaining why a version is pinned.
How the SDK finds the file From the source
- The dotnet command (the SDK muxer) starts in the current working directory and walks up through the parent folders until it finds a global.json.
- The MSBuild project SDK resolver starts in the folder that contains the solution file if there is one, otherwise the folder of the project file, otherwise the current directory, and walks up from there.
- Because the walk starts from where you run the command, the same repository can pick a different file if you run dotnet from a subfolder that has its own global.json, or from outside the repository. Keep one global.json at the repository root.
The version property and feature bands From the source
sdk.version must be a full SDK version such as 10.0.100. Values like 10, 10.0 or 10.0.x are not accepted, and wildcards and ranges are not supported; Microsoft's documentation shows that a value of 10.0 makes dotnet --info report that the version is not valid. To allow a range, combine a full version with rollForward.
SDK versions follow the pattern major.minor.feature-band-and-patch: in 8.0.302, the 3 is the feature band and 02 the patch. If you set a version but no rollForward, the default is patch.
rollForward values From the source
rollForward decides which installed SDKs are acceptable when the exact version is not installed (or, for the latest values, even when it is). Except for latestMajor, it needs a version to go with it.
- patch (default when a version is set): the exact version, or the latest patch in the same feature band. Otherwise the command fails.
- feature: the latest patch in the same feature band, or failing that the next higher feature band of the same major and minor.
- minor: like feature, then the next higher minor version of the same major.
- major: like minor, then a higher major version.
- latestPatch: the highest installed patch in the same feature band that is at least the given version. 8.0.102 with latestPatch accepts 8.0.103 or 8.0.199.
- latestFeature: the highest installed feature band and patch of the same major and minor. 8.0.302 with latestFeature accepts 8.0.303 or 8.0.402, but nothing below 8.0.302.
- latestMinor: the highest installed minor, feature band and patch of the same major.
- latestMajor: the highest installed SDK that is at least the given version. 7.0.200 with latestMajor accepts any 8.0 SDK. This is also what happens when there is no global.json.
- disable: no roll forward at all; only the exact version works. Microsoft recommends it when you use NuGet package lock files, so the SDK and the dependency graph change together.
Prerelease SDKs and the .NET 10 additions From the source
- sdk.allowPrerelease controls whether preview and release candidate SDKs can be selected. Outside Visual Studio it defaults to true. Inside Visual Studio it follows whether you use a preview Visual Studio or the Use previews of the .NET SDK option. Set it to false to keep previews out of your builds.
- sdk.paths (.NET 10 SDK and later): a list of folders to search for SDKs, absolute or relative to the global.json file. The special value $host$ means the folder of the dotnet executable that is running. This lets a repository use an SDK installed into a local .dotnet folder by a setup script.
- sdk.errorMessage (.NET 10 SDK and later): a custom message shown when no matching SDK is found, for example telling developers which install script to run.
- test.runner (.NET 10 SDK and later): chooses the test runner for dotnet test, for example Microsoft.Testing.Platform.
- msbuild-sdks: pins the versions of MSBuild project SDKs in one place instead of in every project file.
What we recommend Analysis
For most teams, latestFeature on the oldest SDK you support is the best balance. It blocks SDKs that are too old, lets developers and build agents use any newer feature band and patch of the same major version, and keeps you on SDKs that receive security fixes. For example, a .NET 10 repository can use version 10.0.100 with rollForward latestFeature.
Avoid disable and patch unless you have a specific reason, such as package lock files or a reproducible release build: exact pins break as soon as a machine updates its SDK, and they tempt people to keep old, unpatched SDKs installed. Remember that Visual Studio installs a single SDK and can remove the previous one when it updates, so a strict pin is most likely to fail on developer machines.
When you move to a new major version, update global.json in the same pull request as the TargetFramework change, and check your CI images install a matching SDK. If you are moving off .NET 8 or 9, which went out of support on 10 November 2026, our upgrade guide walks through the rest.
Sources and further reading
- global.json overview (Microsoft Learn) (original source)
- How to check that .NET is already installed (Microsoft Learn) (documentation)
- Releases and support for .NET (Microsoft Learn) (documentation)
- Download .NET (official)
Original: “global.json overview”, Microsoft Learn, published 18 Nov 2026, retrieved 18 Nov 2026. This article was generated from the official source using our structured templates and passed automated quality checks. Spotted a mistake? See our corrections policy.