4

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?

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Axelly
  • 589
  • 3
  • 7
  • 26
  • The error message says that you forgot to type a space after --sdk-version. Hmm. – Hans Passant Oct 16 '19 at 16:15
  • @HansPassant Console output formats it quite differently, the part after `:` is in newline with `space` before, so I doubt it. `dotnet new --sdk-version "3.0.100-preview7-012821"` – Axelly Oct 16 '19 at 16:16

1 Answers1

8

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.

KyleMit
  • 30,350
  • 66
  • 462
  • 664
DeepForest
  • 96
  • 3
  • Use this command to check the specific API versions you have installed: `dotnet --list-sdks` – Mycah Dec 08 '21 at 19:08