Loic.asadsahi.AspNetCoreSpa
1.0.0
dotnet add package Loic.asadsahi.AspNetCoreSpa --version 1.0.0
NuGet\Install-Package Loic.asadsahi.AspNetCoreSpa -Version 1.0.0
<PackageReference Include="Loic.asadsahi.AspNetCoreSpa" Version="1.0.0" />
<PackageVersion Include="Loic.asadsahi.AspNetCoreSpa" Version="1.0.0" />
<PackageReference Include="Loic.asadsahi.AspNetCoreSpa" />
paket add Loic.asadsahi.AspNetCoreSpa --version 1.0.0
#r "nuget: Loic.asadsahi.AspNetCoreSpa, 1.0.0"
#addin nuget:?package=Loic.asadsahi.AspNetCoreSpa&version=1.0.0
#tool nuget:?package=Loic.asadsahi.AspNetCoreSpa&version=1.0.0
Features
- ASP.NET Core 5.0
- Entity Framework Core 5.0
- Both Sql Server and Sql lite databases are supported (Check installation instrcutions for more details)
- Identity Server 4
- Angular 11
- Angular CLI 11
- Secure - with CSP and custom security headers
- SignalR
- SASS
- Best practices for Angular code organisation.
- Clean Architecture inspired from Jason Taylor.
- PWA support
- Fast Unit Testing with Jest.
- E2E testing with Protractor.l
- Compodoc for Angular documentation
- Login and Registration functionality using Identity Server implicit flow
- Extensible User/Role identity implementation
- Social logins support with token based authentication, using Identity Server
- Angular dynamic forms for reusable and DRY code.
- Swagger as Api explorer (Visit url https://127.0.0.1:5005/swagger OR whatever port visual studio has launched the website.). More details
Pre-requisites
- .Net 5.0 SDK
- Visual studio 2019 OR VSCode with C# extension
- NodeJs (Latest LTS)
- Microsoft SQL Server (Optional: If MS SQL server required instead of Sqlite during development)
- Docker (Optional: If application will run inside docker container)
Installation
Clone the repo:
Change directory:
cd AspNetCoreSpa
Restore packages:
dotnet restore AspNetCoreSpa.sln
Install npm packages:
cd src/Presentation/Web/ClientApp:
npm install
Start Frontend:
- npm start
Run Backend:
Using VSCode:
- If you are running for the first time, install dev certificates using command:
dotnet dev-certs https --trust
- From debug menu select
Web
profile to run api application - From debug menu select
STS
profile to run Identity Server application
Using Visual Studio IDE:
- Run
Web
andSTS
projects either individually or by setting multiple projects in solutions properties and hit F5
- Run
Target either Sqlite or Microsoft SQL Server
This project supports both databases OOTB.
Run with Sqlite: (Already configured to quickly run the project)
- Project is already setup with Sqlite specific database migrations
Run with Microsoft SQL Server:
- Delete
Migrations
folder from src/Infrastructure/Infrastructure/Persistence - Change setting in appsettings.json called
useSqLite
fromtrue
tofalse
and changeWeb
connection string to your local Sql Server connection string
- Delete
Once the project is running use following test users to login:
2 Test users: Username: admin@admin.com Password: P@ssw0rd! OR Username: user@user.com Password: P@ssw0rd!
Note: For production use Identity server hosted with appropriate configuration.
Managing Migrations
Make sure you have ef core global tools installed
dotnet tool install --global dotnet-ef
Web Migrations
Using command line (from root of the project)
Create Migration
dotnet ef migrations add migrationname --startup-project ./src/Presentation/Web --project ./src/Infrastructure/Infrastructure --context ApplicationDbContext -o Persistence/Migrations
Update database
dotnet ef database update --startup-project ./src/Presentation/Web --project ./src/Infrastructure/Infrastructure --context ApplicationDbContext
Drop database
dotnet ef database drop --startup-project ./src/Presentation/Web --project ./src/Infrastructure/Infrastructure --context ApplicationDbContext
Localization Migrations
Using command line (from root of the project)
Create Migration
dotnet ef migrations add migrationname --startup-project ./src/Presentation/Web --project ./src/Infrastructure/Infrastructure --context LocalizationDbContext -o Localization/Migrations
Update database
dotnet ef database update --startup-project ./src/Presentation/Web --project ./src/Infrastructure/Infrastructure --context LocalizationDbContext
Drop database
dotnet ef database drop --startup-project ./src/Presentation/Web --project ./src/Infrastructure/Infrastructure --context LocalizationDbContext
Identity Migrations
Using command line (from root of the project)
Create Migration
dotnet ef migrations add migrationname --startup-project ./src/Presentation/STS --project ./src/Infrastructure/Infrastructure --context IdentityServerDbContext -o Identity/Migrations
Update database
dotnet ef database update --startup-project ./src/Presentation/STS --project ./src/Infrastructure/Infrastructure --context IdentityServerDbContext
Drop database
dotnet ef database drop --startup-project ./src/Presentation/STS --project ./src/Infrastructure/Infrastructure --context IdentityServerDbContext
Other commands
Angular component scaffolding
Note: You need to run commands from src/Presentation/Web/ClientApp
directory: More information here
Angular tests - Using Jest and Angular jest preset
cd src/Presentation/Web/ClientApp
npm test
Compodoc Angular documentation
- Steps to generate:
- npm i compodoc -g
- cd src/Presentation/Web/ClientApp
- npm run compodoc
- cd documentation
- http-server
Compodoc documentation:
### run end-to-end tests
```bash
# make sure you have your server running in another terminal (i.e run "dotnet run" command)
npm run e2e
run Protractor's elementExplorer (for end-to-end)
npm run webdriver:start
# in another terminal
npm run e2e:live
Azure Deploy
- You can set an environment variable for azure app deployment password Set-Item -path env:AzureAppPass -value passwordhere
From powershell:
./deploy-azure.ps1
Deploy to heroku using its container service
Replace your app name where it is aspnetcorespa
- dotnet publish -c release
- docker build -t aspnetcorespa ./bin/release/net5.0/publish
- heroku login
- heroku container:login
- docker tag aspnetcorespa registry.heroku.com/aspnetcorespa/web
- docker push registry.heroku.com/aspnetcorespa/web
Note: There is a
deploy.heroku.ps1
script included with this project which automates above steps.
Deploy to Azure as App Service
Set-Item -path env:AzureAppPass -value passwordhere
From powershell:
./deploy-azure.ps1
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net5.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 0 | 7/31/2021 |