Reputation: 234
I am trying to run a [.NET Core + Angular] project, but encountering a bunch of errors. The .NET Core version of the project is 3.1.
The very first error I got was:
The NPM script 'start' exited without indicating that the Angular CLI was listening for requests.
So, I consulted THIS resource -> https://www.c-sharpcorner.com/blogs/the-npm-script-start-exited-without-indicating-that-the-createreact and accordingly proceeded to comment out the snippet under IsDevelopment()
.
Which again, led to this current error I have posted in the question title.
I consulted few resources, and according to one of them added the following piece of code in Startup.cs
:
spa.Options.SourcePath = "ClientApp/dist";
That doesn't resolve it. Mind you, I am not deploying to Azure or IIS, simply launching the project from Visual Studio 2022.
I checked angular.json
of ClientApp and found that "outputPath": "dist"
is set there in the 'build'
section.
If you follow THIS resource-> https://learn.microsoft.com/en-us/answers/questions/1624504/invalidoperationexception-the-spa-default-page-mid
it tells you to configure Startup.cs
further as:
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(app.Environment.ContentRootPath, "ClientApp", "dist")),
RequestPath = ""
});
But applying that code causes this error
'IApplicationBuilder' does not contain a definition for 'Environment' and no accessible extension method 'Environment' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?)
In the launchSettings.json file I checked that the env. variable is set to "Development":
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
As last ditch attempt, I experimented with adding the following 2 lines in the .csproj
project file:
<Content Include="ClientApp\dist\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
This corrupts the whole project, and it does not load.
So what's all this ruckus about? How do I get this SPA .NET Core + Angular project launching without these glitches? Let me know, if you need more details about project configuration, settings etc to understand the cause of this misbehavior. Will share.
Thanks,
Upvotes: 0
Views: 27