ASP.NET Core (.NET 5) + Angular 11 = 在空项目上构建错误

编程入门 行业动态 更新时间:2024-10-23 11:28:36
本文介绍了ASP.NET Core (.NET 5) + Angular 11 = 在空项目上构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我在 Visual Studio 中使用:dotnet new angular 创建一个新的 ASP.NET Core Web API + 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 --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 serve,它可以正常工作.

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!

推荐答案

我遇到了类似的问题,甚至 询问.然而,正如回复所暗示的那样,这是一个 Angular 产生的结果,这些结果在 .NET 中无意中看起来像是错误 - 基本上是编码草率的情况.

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 最新的东西.在我看来,您绝对应该继续使用第 11 个(或任何最新版本).

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 = 在空项目上构建错误

本文发布于:2023-11-17 06:56:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609224.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   项目   NET   ASP   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!