After finding several confusing articles with hit-and-miss results, I thought I would record the simplest process I have found for creating a new Angular/ASP.NET web application.
The tools I am using
- Git: https://www.nuget.org/downloads
- Node.js, version 16.14.0: https://nodejs.org/en/download/
- npm, version 8.3.1 (included in the Node install)
- VS Code, version 1.65.1: https://code.visualstudio.com/download
Getting started
mkdir [yourapplicationname]
Then
cd [yourapplicationname]
dotnet new angular [yourapplicationname]-UI
- Do I care about using the latest versions of everything (specifically, Angular)?
- Am I keeping this as simple as possible, or do I want to emulate a real production application?
Quick and easy - with an old version
Almost as quick and easy - with the newest shinies
cd c:\dev\[yourapplicationname]\[yourprojectname]-UI
Remove the Angular code created by dotnet:
rmdir ClientApp
Create a new Angular client app:
ng new ClientApp
You will be prompted to add Angular routing. Type "y" to accept.
You will be prompted for a stylesheet format. Just hit enter to accept the pre-selected CSS.
Testing the base application
At the time of this article's publication, you may see some false error messages from Microsoft.AspNetCore.SpaServices[0] like
Generating browser application bundles (phase: setup)... or
Γ£ö Browser application bundle generation complete.
These are due to the dotnet CLI misinterpreting progress output from Angular (see https://github.com/dotnet/aspnetcore/issues/21793). There seems to be a stalemate currently on which team is going to address this so -- if it bothers you -- you can turn off Angular output by opening angular.json and adding "progress": false,
"architect": {"build": {"builder": "@angular-devkit/build-angular:browser","options": {"progress": false,"outputPath": "dist/client-app",
Once the app is running, you can open a browser window to https://localhost:5001/.