Skip to main content

global.json file

 

Symptoms

Suddenly you get build errors in your build pipeline which perfectly builds in your local machine 🤔🤔🤔

Cause

Most likely the root cause is .NET SDK versions. Your local machine builds on a different SDK and the pipeline builds on a different SDK.

Resolution

The ideal way of solving this is to force everyone to use one define .Net SDK. Regardless of whether it is a developer or CI pipeline.

Simply to make this happen .NET  provides you a file called "global.json".

The global.json file allows you to define which .NET SDK version is used when you run .NET CLI commands. Selecting the .NET SDK version is independent from specifying the runtime version a project targets.
For information about specifying the runtime version instead of the SDK version, see Target frameworks.

If you always want to use the latest SDK version that is installed on your machine, no global.json file is needed.

Into the Depth

The sample global.json file looks like the below,
{ 
    "sdk": { 
        "version": "3.1.100", 
        "rollForward": "disable" 
        "allowPrerelease": false 
    } 
}

version: String

The version of the .NET SDK to use.

allowPrerelease: Boolean

Indicates whether the SDK resolver should consider prerelease versions when selecting the SDK version to use.

rollForward: String

The roll-forward policy to use when selecting an SDK version, either as a fallback when a specific SDK version is missing or as a directive to use a higher version.

To set an SDK version in the global.json file, it's helpful to know which SDK versions are installed on your machine. How to do that,
Type this one your command line
dotnet --list-sdks
This command will give you all the installed SDK versions like the below,
3.1.424 [C:\program files\dotnet\sdk] 5.0.100 [C:\program files\dotnet\sdk] 6.0.402 [C:\program files\dotnet\sdk] 7.0.100 [C:\program files\dotnet\sdk]

You can create a new global.json file in the current directory by executing the dotnet new command, similar to the following example:
dotnet new globaljson --sdk-version 6.0.100


May the force be with you!

Comments

Popular Posts

SSAS: The Sort Order Specified For Distinct Count Records Is Incorrect.

Symptoms During a processing time of a cube that contains a distinct count measure, the process fails with the following error message: The sort order specified for distinct count records is incorrect Cause This is most likely caused by different sort order used on the data warehouse data set and the analysis service database data set. Resolution Modify the sort order of the data warehouse data set so that it will match with the analysis service database data set. Into the Depth  Navigate to the analysis database and start to process the desired database. When the processing begins, the Process progress window will pop up. Wait till the process gets failed. After the process failed, find the failing measure group and expand to the last node where you can see an SQL query. Double click on the query and view the details. This query gives you the exact order by the column which caused you this trouble.  Execute the query using the data warehouse datab...

ASP.NET Core 3.1 - Setting up React app with Typescript

With the release of .NET Core 3.1, I have decided to migrate one of my .NET core 2.1 solutions which contain ASP.NET core API project, React Web project (ASP.NET core project with react typescript template) and .NET Core Library project.  So I started the migration with the Library and API projects. Based on my experience, I think it was not a smooth migration due to the vast number of breaking changes but I managed to up and run both projects. Lastly, I have started to migrate the React ASP.NET core project. It was chaotic but I managed to up and run the project. Thought it worked I got some issues here and there so I decided not to continue with the same project rather create a new ASP.NET Core 3.1 React TypeScript template project. When you are going to create a new project, Visual Studio provided you a list of templates where you can pick desired Even though we have a project template for ASP.NET Core with React JS, there is no direct project templ...

Satellite Assembly in C#

Satellite Assemblies Resource files in Dot Net Resource files are typically used to store any resources in your Dot Net application. Resource file allows you to store images, icons, audio, files, strings and other types of resources. Of cause it is not mandatory to keep them inside a resource file. But when it comes to localization it is recommended to work with the resource file. localization Which means based on the user's language and culture change the application and the resources. How to archive localization with resources? Seems to be an impossible task. But to make the impossible possible, Dot Net provides you a special assembly called "Satellite Assembly" Satellite assemblies are assemblies that containing resources specific to a given language and culture. Using satellite assemblies, you can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user selects to view the ...