Skip to content

Instantly share code, notes, and snippets.

@nul800sebastiaan
Created November 4, 2021 09:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nul800sebastiaan/9950ca3dd23943f03f46b56cfd39aff3 to your computer and use it in GitHub Desktop.
Save nul800sebastiaan/9950ca3dd23943f03f46b56cfd39aff3 to your computer and use it in GitHub Desktop.
Install VS templates for multiple frameworks

Go into a folder, let's say C:\MyTest Run: dotnet new globaljson This will create a global.json file with your current version of the dotnet CLI in it, for example:

{
  "sdk": {
    "version": "6.0.100-rc.2.21505.57"
  }
}

So in this case, when you do dotnet new -i Umbraco. Templates::* the VS templates will be installed for version 6-RC2 of the framework. Visual Studio 2022 runs dotnet v6 by default but VS2019 runs dotnet 5 by default.

In order to figure out which versions we have available on our machine, you can run dotnet --list-sdks, the example output could be:

3.1.414 [C:\Program Files\dotnet\sdk]
5.0.402 [C:\Program Files\dotnet\sdk]
6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]`

So we can update the global.json file, which overrides the framework version used in that directory and below:

{
  "sdk": {
    "version": "5.0.402"
  }
}

Now when we run dotnet new -i Umbraco. Templates::*, it will install the dotnet templates in dotnet framework 5, which should make them available in VS2019.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment