在Mac上使用Visual Studio创建一个新的Angular项目

5

我正在学习如何使用Visual Studio在Mac上(macOS Sierra,Visual Studio Community 2017)设置Spa应用程序。这里是教程链接:https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2017-Launch/WEB-103

我已经成功安装了Angular Core,并且正在尝试基于其中一个已安装的模板创建新项目。

当我运行sudo dotnet new -l时,可以看到两个Angular模板:

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

但是当我运行sudo dotnet new angular时,一直出现以下错误:

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

我是否漏掉了命令中的某些部分?Visual Studio / dotnet 是否配置不正确?


你是如何安装模板的?安装方式是 dotnet new --install Microsoft.AspNetCore.SpaTemplates::* - Hackerman
@Hackerman 是的!实际上,那正是我所做的。 - narner
哦,出现了“找不到名为'angular'的卸载对象”的错误。@黑客人员 - narner
4
执行命令 dotnet new --debug:reinit 并查看模板列表。 - Hackerman
2
您可以随时查看文档 https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet - Hackerman
显示剩余2条评论
2个回答

6
要安装单页应用程序(SPA)模板,请运行以下命令:
dotnet new --install Microsoft.AspNetCore.SpaTemplates::*

在此输入图片描述

现在可以创建任何单页应用(SPA)……

dotnet new angular -o ngApp
cd .\ngApp\
npm install
dotnet restore
dotnet run

2
请不要修改@PaulRoub的编辑,Muhammad - 这是一个好的编辑。我们不鼓励在这里使用问候语、签名和署名,如果这样的编辑成为编辑战争的主题,版主会更倾向于没有这些内容的版本。 - halfer

2

使用 .netcore 2.1

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

现在在2.1版本中,package.json文件位于客户端应用程序内部。

    cd ClientApp
    npm install
    dotnet restore
    dotnet run

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接