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/.
4 comments:
best blog
The article does a good job of breaking down the process of creating an ASP.NET Core application with an Angular frontend into manageable steps. The comparison between using the generated Angular version and replacing it with a newer setup is particularly useful, since developers need to consider both simplicity and framework version requirements when starting a project.
For developers following this approach, Angular Training can help build a stronger understanding of the frontend framework, including project structure, components, services, and application development.
The TypeScript side is equally important when working with modern Angular applications because much of the application code relies on typed classes, interfaces, and tooling. TypeScript Training can therefore complement the Angular concepts discussed in the article.
Post a Comment