Kaze
Kaze

Reputation: 47

Visual Studio 22 Multiple Startup Projects

I`m using VS 2022 Professional 2022 (17.2.0).

I wanted to create a ASP.Net Core app with Angular in VS and used the Microsoft Tutorial for it. https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-angular?view=vs-2022

When I want to start Multiple Project as once, only Angular CLI will start the ng start command, but the ASP.NET Core Project will never start. When I disable the Angular Project inside, Multiple Startprojects, the .Net Core Console will start.

Creation started...
1>------ Build started: Project: ConverterBackend, Configuration: Debug Any CPU ------
2>------ Build started: Project: Converter, Configuration: Debug Any CPU ------
1>Analyzer tools are skipped to speed up the build. You can run the Build or Rebuild command to run the analyzer.
1>ConverterBackend -> C:\Optimization\Converter\ConverterBackend\bin\Debug\net6.0\ConverterBackend.dll
3>------ Deployment started: Project: Converter, Configuration: Debug Any CPU ------

Settings:

Multiple Projects Startup Config Manager

.NET Debug Settings Visual Studio Bar

proxy.conf.js

target: "https://localhost:7049",

launchSettings.json

"applicationUrl": "https://localhost:7049;https://localhost:5001",

I hope somebody has a Solution or run into the same Error once, cause I cant find anything about this. Could this be an AV problem?

Solution: If u ever run into this Problem Check Script Execution permissions and if the AV blocks something.

Upvotes: 2

Views: 2917

Answers (3)

chick3n0x07CC
chick3n0x07CC

Reputation: 798

I was also struggling with this and finally found a solution thanks to this user. It might not be viable for everyone since it requires a version downgrade but I'll share it: I was using Node.js v18.12.1 (LTS at the time) (64-bit). I had installed it with nvm for Windows. With this set up, OP problem is reproduced.

Then, I used nvm to switch to Node v16.18.1 (64-bit). With this change the frontend and backend run perfect as expected from the tutorial.

Edit:

Another solution to avoid the downgrade is keep using Node.js v18.12.1 and just add --host 0.0.0.0 to the start command in Angular package.json:

"start": "ng serve --host 0.0.0.0 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key"

This works but I can't provide an explanation for why. But it requires adding a rule to the Windows firewall (you probably get a prompt asking you for permission).

Upvotes: 2

heikofritz
heikofritz

Reputation: 131

You have to start the ASP.Net Core app. In there you should have a Startup Class. Go to Configure Services and add something like this:

services.AddSpaStaticFiles(configuration => { configuration.RootPath = "WebUI"; });

Then the Kestrel Server should start up with the SPA.

Upvotes: 1

tmaj
tmaj

Reputation: 34967

I use two instances of VS open for this; each with a different start up project.

Upvotes: 0

Related Questions