Move .NET example to a new file

This commit is contained in:
James Skemp 2023-09-04 07:44:32 -05:00
parent 0bbd1124c5
commit 8f8231c26e
3 changed files with 51 additions and 49 deletions

View File

@ -16,6 +16,7 @@
- [SQLite](./sqlite.md)
- [Angular](./angular.md)
- [.NET](./dotnet.md)
- [Examples](./dotnet/examples.md)
- [Go](./golang.md)
- [Docker](./docker.md)
- [Windows Terminal](./windows-terminal.md)

View File

@ -99,52 +99,3 @@ using (var scope = app.Services.CreateScope()) {
dotnet ef migrations add InitialCreate -o Data/Migrations
dotnet ef database update
```
## Example: .NET API with Angular Frontend and XUnit Testing
This example sets up a new .NET webapi project with XUnit testing and an Angular frontend.
```bash
# From repo root:
dotnet new sln
dotnet new webapi -o API
dotnet sln add API
dotnet new gitignore
git init
git add .
git commit -m "Add new .NET webapi project and solution"
# XUnit project.
dotnet new xunit -o API.Tests
dotnet add .\API.Tests\API.Tests.csproj reference .\API\API.csproj
dotnet sln add API.Tests
git add .
git commit -m "Add new XUnit project"
# Create Angular application.
ng new client
git add .
git commit -m "Add new Angular application"
```
## Running via Windows Terminal
```bash
wt -d .\ --title 'Repo Root' `; nt -d .\client\ --title 'ng serve' `; split-pane -H -d .\API\ --title 'dotnet watch run' `; nt -d .\client\src\app\ --title 'ng g ...'`; nt -d .\client\ --title 'ng test' `; split-pane -H -d .\ --title 'dotnet test'
```
### Alternatively
```bash
# From repo root:
cd .\API\
dotnet run
# From repo root:
dotnet test
# From repo root:
cd .\client\
ng serve
# From repo root:
cd .\client\
ng test
```

50
src/dotnet/examples.md Normal file
View File

@ -0,0 +1,50 @@
# .NET Examples
## Example: .NET API with Angular Frontend and XUnit Testing
This example sets up a new .NET webapi project with XUnit testing and an Angular frontend.
```bash
# From repo root:
dotnet new sln
dotnet new webapi -o API
dotnet sln add API
dotnet new gitignore
git init
git add .
git commit -m "Add new .NET webapi project and solution"
# XUnit project.
dotnet new xunit -o API.Tests
dotnet add .\API.Tests\API.Tests.csproj reference .\API\API.csproj
dotnet sln add API.Tests
git add .
git commit -m "Add new XUnit project"
# Create Angular application.
ng new client
git add .
git commit -m "Add new Angular application"
```
### Project Workspace via Windows Terminal
```bash
wt -d .\ --title 'Repo Root' `; nt -d .\client\ --title 'ng serve' `; split-pane -H -d .\API\ --title 'dotnet watch run' `; nt -d .\client\src\app\ --title 'ng g ...'`; nt -d .\client\ --title 'ng test' `; split-pane -H -d .\ --title 'dotnet test'
```
### Alternatively
```bash
# From repo root:
cd .\API\
dotnet run
# From repo root:
dotnet test
# From repo root:
cd .\client\
ng serve
# From repo root:
cd .\client\
ng test
```