liveBook · Manning

Globaljson template

As explained in Pro ASP.NET Core 7, Tenth Edition

The globaljson template is a .NET project template that creates a global.json file for selecting the SDK version used by a project.

The globaljson template adds a global.json file that selects the .NET SDK version used by a project. Pinning the SDK helps a development team obtain consistent results despite framework changes. section 4.1.1

Pin an SDK for a new project

Run `dotnet new globaljson --sdk-version 7.0.100 --output MySolution/MyProject` before creating the project. Then create the application with `dotnet new web --no-https --output MySolution/MyProject --framework net7.0`. section 4.1.1

The template fits into a wider command-line setup:

  • Use the web template for the minimal ASP.NET Core project, then create and populate a solution with `dotnet new sln` and `dotnet sln ... add`. section 4.1.1
  • Place global.json in the intended project hierarchy so the SDK selection applies to the project. section 4.1.1
Table 4.3 The configuration item templates (view table figure)

Name

Description

globaljson

This template adds a global.json file to a project, specifying the version of .NET that will be used.

sln

This template creates a solution file, which is used to group multiple projects and is commonly used by Visual Studio. The solution file is populated with the dotnet sln add command, as shown in listing 4.2.

gitignore

This template creates a .gitignore file that excludes unwanted items from Git source control.

Compare globaljson with related configuration item templates such as solution and Git-ignore generation. section 4.1.1

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Defines the template’s purpose and demonstrates one command, but does not detail global.json properties or SDK resolution.
Examples
Uses a .NET 7.0.100 SDK pin alongside a net7.0 web project and a generated solution.
What it assumes
Assumes command-line access and basic familiarity with .NET project and solution creation.
What you can do after
Operate/configure the .NET CLI to pin an SDK before generating a consistent project structure.
How it connects
Connects SDK selection with project templates, solution files, ASP.NET Core development, and .NET framework selection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.