ASP.NET Core(.NET 5)+ Angular 11 =在空项目上生成错误 [英] ASP.NET Core (.NET 5) + Angular 11 = build error on empty project
问题描述
如果我使用以下代码在Visual Studio中创建新的ASP.NET Core Web API + Angular项目 : dotnet new angular
,它将创建 .NET 5 项目,在ClientApp中包含一个新的 Angular 8.2 项目.
如果我 F5 ,一切正常.
If I create a new ASP.NET Core Web API + Angular project in Visual Studio using: dotnet new angular
, it creates a .NET 5 project containing in the ClientApp a new Angular 8.2 project.
If I F5 it, everything works perfectly.
但是我想使用Angular 11项目,所以我擦除了ClientApp内容,在那里打开了一个终端,然后: ng new< app-name>--directory ./
在那里.
But I want to use and Angular 11 project, so i wipe the ClientApp content, open a terminal there and: ng new <app-name> --directory ./
there.
创建的项目 F5 ,该项目将启动,但是每次启动时,这两行都会显示在调试控制台中:
Project created, F5, the project launches but at every launch these 2 lines appear in the Debug Console:
Microsoft.AspNetCore.SpaServices:错误:-生成浏览器应用程序捆绑包...Microsoft.AspNetCore.SpaServices:错误:已完成浏览器应用程序捆绑包的生成.
Microsoft.AspNetCore.SpaServices: Error: - Generating browser application bundles... Microsoft.AspNetCore.SpaServices: Error: √ Browser application bundle generation complete.
我做了很多尝试:合并以前的 tsconfig.json
, angular.json
, launchSettings.json
中的值,但没有任何解决方案.
相反,如果我从ClientApp目录启动 ng服务
,它将正常工作.
I did many attempts: merging values from previous tsconfig.json
, from angular.json
, launchSettings.json
, but nothing solved it.
Instead, if I launch an ng serve
from the ClientApp directory, it works without errors.
Visual Studio与Angular的CLI之间是否存在某些不兼容?预先谢谢大家!
Is there some incompatibility between Visual Studio and Angular's CLI? Thank you all in advance!
推荐答案
I get similar issues and even asked about it. However, as the replies suggest, it's a matter of Angular producing results that unintentionally look like errors to .NET - basically a case of sloppy coding.
虽然我认识到您的痛苦并与您分享,但您需要接受MS落后于Angular最新产品的情况.我认为您绝对应该继续使用11th(或任何最新版本).
While I recognize your pain and do share it with you, you'll need to accept that MS is a bit behind Angular latest stuff. You should definitely keep going with 11th (or whatever version is the latest), in my opinion.
这篇关于ASP.NET Core(.NET 5)+ Angular 11 =在空项目上生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!