简体   繁体   English

Visual Studio 阻止部署独立 Angular 项目

[英]Visual Studio blocks on deploying a Standalone Angular project

I am using the latest version of Visual Studio 2022, which is 17.2.6.我使用的是最新版本的 Visual Studio 2022,即 17.2.6。

If I create a new project of the type "Standalond Typescript Angular Project" , make no modifications whatsoever and try to start the project, then it opens a console window with title ngcc and (after a while) shows the following content:如果我创建一个类型为“Standalond Typescript Angular Project”的新项目,则不进行任何修改并尝试启动该项目,然后它会打开一个控制台window ,同时显示以下内容:

> angularproject1@0.0.0 start
> ng serve

√ Browser application bundle generation complete.

Initial Chunk Files   | Names         |      Size
vendor.js             | vendor        |   1.67 MB
polyfills.js          | polyfills     | 336.18 kB
styles.css, styles.js | styles        | 212.40 kB
main.js               | main          |  53.50 kB
runtime.js            | runtime       |   6.87 kB

                      | Initial Total |   2.26 MB

Build at: 2022-07-16T15:17:53.888Z - Hash: ad802c438fec0f97 - Time: 12103ms

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **


√ Compiled successfully.

At this point I can open the address http://localhost:4200/ in a browser and it loads the page correctly.此时我可以在浏览器中打开地址 http://localhost:4200/ 并正确加载页面。

However, Visual Studio gets stuck showing the text "Deploy started..." in the status bar.但是,Visual Studio 卡在状态栏中显示文本“部署开始...”。

The Visual Studio output window has the following content: Visual Studio output window 有以下内容:

Build started...
1>------ Build started: Project: angularproject1, Configuration: Debug Any CPU ------
2>------ Deploy started: Project: angularproject1, Configuration: Debug Any CPU ------

If I abort the program in the console, the Visual Studio shows the message如果我在控制台中中止程序,Visual Studio 会显示消息

There were deployment errors. Continue?

In another scenario, I have created a solution with two new projects:在另一种情况下,我创建了一个包含两个新项目的解决方案:

  • "Standalond Typescript Angular Project" 《标准Typescript Angular项目》
  • "ASP.NET Core Web API" “ASP.NET Core Web API”

and made them both startup projects (with the Web APU starting first).并使它们成为启动项目(首先启动 Web APU)。 This is the scenario that I actually want to use.这是我真正想要使用的场景。

In this case I get exactly the same effect, but the single "Standalond Typescript Angular Project" seems to be the easiest way to reproduce the problem.在这种情况下,我得到了完全相同的效果,但单个“Standalond Typescript Angular Project”似乎是重现问题的最简单方法。

Why is Visual Studio hanging up in the deployment step?为什么 Visual Studio 在部署步骤中挂起?

EDIT编辑

I have made another test, exactly following the instructions on the following page:我完全按照下一页上的说明进行了另一次测试:

https://docs.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-angular?view=vs-2022 https://docs.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-angular?view=vs-2022

The behavior is identical, Visual Studio hangs up waiting for the deployment to be completed.行为是相同的,Visual Studio 挂起等待部署完成。

Had the exact problem.有确切的问题。 The fix for me was to install a different Node version.对我来说,解决方法是安装不同的 Node 版本。

Using the nvm version manager for Node I was able to install the latest using:使用 Node 的nvm版本管理器,我可以使用以下方法安装最新版本:

nvm install lts

In my case, it installed v16.16.0.就我而言,它安装了 v16.16.0。 Then I set as current using:然后我设置为当前使用:

nvm use v16.16.0

I encountered the same behavior in Visual Studio 2022. In my solution are two Angular and two API-Projects.我在 Visual Studio 2022 中遇到了相同的行为。在我的解决方案中,有两个 Angular 和两个 API 项目。 I wanted to start them both but one got stuck like you mentioned.我想同时启动它们,但像你提到的那样卡住了。

The reason in my case was, that for the second angular project I changed the port.我的原因是,对于第二个 angular 项目,我更改了端口。 I found out, when you change the standard in ng serve to something different than 4200 it will not recognize that the server is up and running.我发现,当您将 ng serve 中的标准更改为不同于 4200 的内容时,它不会识别出服务器已启动并正在运行。 It seems to me he is checking exactly this port.在我看来,他正在检查这个端口。

Ok, you write you use 4200. In my case in the multi startup the angular apps are first.好的,你写你使用 4200。在我的情况下,在多启动中,angular 应用程序是第一个。 That's different.那不一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM