5

I'm currently going through a https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2017-Launch/WEB-103 on setting up Spa apps with Visual Studio on Mac (macOS Sierra, Visual Studio Community 2017).

I've successfully installed angular core, and am currently trying to create a new project based off of one of the installed templates.

I can see two angular templates when I run sudo dotnet new -l:

MVC ASP.NET Core with Angular angular [C#] Web/MVC/SPA ASP.NET Core with Angular angular [C#] Web/MVC/SPA

When running sudo dotnet new angular, I keep getting the following error:

Unable to determine the desired template from the input template name: angular.
The following templates partially match the input. Be more specific with the template name and/or language.

Templates                          Short Name      Language      Tags       
----------------------------------------------------------------------------
MVC ASP.NET Core with Angular      angular         [C#]          Web/MVC/SPA
ASP.NET Core with Angular          angular         [C#]          Web/MVC/SPA


Examples:
    dotnet new angular
    dotnet new angular
    dotnet new --help

Is there something in the command I'm missing? Is something with Visual Studio / dotnet configured incorrectly?

Zze
  • 18,229
  • 13
  • 85
  • 118
narner
  • 2,908
  • 3
  • 26
  • 63
  • How did you install the templates?, the way to do it is `dotnet new --install Microsoft.AspNetCore.SpaTemplates::*` – Hackerman Jun 29 '17 at 18:32
  • @Hackerman Yup! That's exactly what I did, actually. – narner Jun 29 '17 at 18:34
  • We can test one thing....what am I thinking is that the default installation of VS 2017 in your MAC, already install the angular template...what you can do is run `dotnet new -u angular`...then check that both templates are gone....then install again using the `dotnet new --install Microsoft.AspNetCore.SpaTemplates::*` – Hackerman Jun 29 '17 at 19:15
  • Hmm - got `Could not find something to uninstall called 'angular'. @Hackerman – narner Jun 29 '17 at 19:18
  • 4
    Run this command `dotnet new --debug:reinit ` and check the template list – Hackerman Jun 29 '17 at 21:41
  • @Hackerman this solved my issue. Could you suggest where can one learn more on the dotnet commands? – Anton Toshik Jul 07 '17 at 19:44
  • 2
    You can always check the documentation https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet – Hackerman Jul 07 '17 at 19:46

2 Answers2

6

To install the Single Page Application (SPA) templates, run the following command:

dotnet new --install Microsoft.AspNetCore.SpaTemplates::*

enter image description here

Now create any SPA ...

dotnet new angular -o ngApp
cd .\ngApp\
npm install
dotnet restore
dotnet run
halfer
  • 19,824
  • 17
  • 99
  • 186
  • 2
    Please leave @PaulRoub's edit be, Muhammad - it was a good edit. We discourage salutations, greetings, sign-offs and signatures here, and if such edits become the subject of an edit war, a moderator will tend to prefer the version without them. – halfer Oct 09 '17 at 09:20
2

With .netcore 2.1

dotnet new angular -o my-new-app
cd my-new-app

Now on 2.1 the package.json is inside client app

    cd ClientApp
    npm install
    dotnet restore
    dotnet run
San Jaisy
  • 15,327
  • 34
  • 171
  • 290