Templating: Cannot create netcoreapp1.x templates after installing 2.0 CLI

Created on 26 Jul 2017  路  5Comments  路  Source: dotnet/templating

Installing the 2.0 CLI makes netcoreapp1.x templates inaccessible

Repro
Install .NET Core SDK 1.0.4
dotnet new web --framework netcoreapp1.1. Works 馃槃

Install .NET Core SDK 2.0.0
dotnet new web --framework netcoreapp1.1.

Expected
The template system sees that both a 1.0 and 2.0 SDK are installed and fallsback to the 1.0 SDK for frameworks the 2.0 SDK doesn't include

Actual

Error: Invalid parameter(s):
--framework netcoreapp1.1
    'netcoreapp1.1' is not a valid value for --framework (Framework).

Workaround
Before invoking dotnet new, create a global.json file and point dotnet to the old version.

{ "sdk": { "version": "1.0.4" }}

All 5 comments

This is actually by design. The dotnet CLI 2.x does not ship with the 1.x templates because the 2.x CLI does not carry the 1.0/1.1 runtimes. But you can install the 1.x templates on your 2.x CLI install. To install them, add this myget feed to your global NuGet.config: https://dotnet.myget.org/F/templating/api/v3/index.json, and then install the desired template packs using one or more of these commands:

dotnet new -i Microsoft.DotNet.Common.ProjectTemplates.1.x::1.0.0-*
dotnet new -i Microsoft.DotNet.Test.ProjectTemplates.1.x::1.0.0-*
dotnet new -i Microsoft.DotNet.Web.ProjectTemplates.1.x::1.0.0-*

Good to know there is a way to install these templates, though I would never have discovered this on my own. Also, this is rather cumbersome, especially the part where I have to (1) find and (2) edit the global nuget.config file. Could this story be improved?

  • Add instructions of installing the old templates to the error message
  • Add a --source flag to dotnet new -i so I don't have to find the global NuGet.config file.
  • Auto-install the templates when a recognized but not-bundled-by-default target framework is specified.
$ dotnet new web --framework netcoreapp1.1
Error: 'netcoreapp1.1' is not a recognized framework for installed templates.
Would you like to install the templates for 'netcoreapp1.1'? [Y/n]
Y
Installing 'Microsoft.DotNet.Web.ProjectTemplates.1.x::1.0.0-*' from 'https://dotnet.myget.org/F/templating/api/v3/index.json'

Good suggestions - I agree, how to install the 1.x templates is not really discoverable.
@mlorbetske @sayedihashimi - any thoughts on how to best convey to the user how to install 1.x templates on the 2.x CLI? This is likely to come up again.

We are discussing / planning a user experience similar to your third suggestion - here: https://github.com/dotnet/templating/issues/1084 - please let us know if you have additional thoughts on what you'd expect / prefer from that sort of functionality. It would also make the need for editing your NuGet.config file unnecessary.

In your system higher version of core is available. So to fix the issue type this command
dotnet new mvc --language C# --auth None --framework netcoreapp2.1 and it will work.

Always version which is installed in your system.

My original question was answered. We can use #1084 for follow-up.

Was this page helpful?
0 / 5 - 0 ratings