Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet cli how to create project using previous sdk/framework? [duplicate]

Tags:

c#

dotnet-cli

Let's say that I'm using Core 3.0 with Blazor templates installed

My VS updated and downloaded sdk 3.1 preview X and now my dotnet cli works in 3.1 preview by default

so using dotnet new doesn't show my installed Blazor templates that I installed while using 3.0

I tried those commands to at least see name of previous templates or actually create 3.0 Blazor project, but nothing works

dotnet new --sdk-version "3.0.100-preview7-012821"
dotnet new --framework "netcoreapp3.0"

# Invalid input switch:--sdk-version3.0.100-preview7-012821

How can I list dotnet new templates for previous sdk/framework and then actually create them?

like image 880
Axelly Avatar asked Sep 19 '25 05:09

Axelly


1 Answers

Based on the docs on how to select the .NET version to use:

Create a global.json file in your new project folder with the following content (for .net core 2.2.203 - change to required version):

{
  "sdk": {
    "version": "2.2.203"
  }
}

From a command line cd into that folder and run: dotnet new choose-template-name

Running any dotnet CLI command in this folder and sub-folders, will use the specified SDK.

Make sure the SDK is installed first, of course.

like image 157
DeepForest Avatar answered Sep 20 '25 20:09

DeepForest