This is a template you can use to quickly create a multiplatform ASP.NET Core 6 application that runs an API server and a worker process as two projects under one solution. It also features fully configured packages that I use the most when developing ASP.NET apps, which are:
- AutoMapper - an object mapper with a dependecy injection extension
- Dapper - a simple ORM mapper
- Dapper.SimpleCRUD.yasikovsky - a fork of Dapper.SimpleCRUD, a library for CRUD helpers for Dapper
- Microsoft.AspNetCore.Authentication.JwtBearer - for generating and serving JWT tokens
- Npgsql - a PostgreSQL data provider
- Serilog - a logging library with a bunch of extensions -- Serilog.AspNetCore for dependency injection -- Serilog.Exceptions for better exception handling -- Serilog.Sinks.Console for native console logging
- ServiceStack.Text - useful JSON manipulation library
- Swashbuckle.AspNetCore - for automagically generating Swagger API documentation
Also has a bunch of extension methods and useful methods I've written over the years and come back to all the time:
- Custom Database Gateway service for Database queries with dependency injection
- Custom PostgreSQL Database resolver for Dapper.SimpleCRUD
- Custom Dapper type handlers for Enums (generic), List<Guid>, List<string>, List<int>, RoleType and object (serialized to JSON)
- Role and Claim support with RequireRole and RequireClaim attributes that work with controllers and also generate Swagger annotations
- FilterModel and SqlFilterAttribute classes that help translate data request models with filters and sorting to database queries with joins across multiple tables
- solution-wide appsettings.json and appsettings.[environment].json to set-up config files once and share them between the API and Worker projects
- .NET 6 SDK for platform of your choice
- ASP.NET Core 6 Runtime for the above
- Install the template nuget package:
dotnet new --install yasikovsky.AspNetCoreTemplate
- Navigate to your empty project folder
- Create a project files using the template
With example values:
dotnet new yaspnet
Or with your own options:
dotnet new yaspnet --ProjectName "MyProject" --DbHostname "127.0.0.1" --DbPort "5432" --DbDatabase "mydatabase" --DbUsername "myusername" --DbPassword "mypassword" --GitHubOrgName "my-org-name"
- Finish it up with restoring NuGet packages:
dotnet restore
1.0.0
- Initial release
1.1.0
- Added Dockerfiles
- Added Preconfigured Docker-compose.yaml file with example environment variable file
- Added Github Actions runner to publish Docker packages to GitHub package repository when creating new release (important to tag them in the vX.X.X format)
- PasswordSalt is now a random UUID
- JwtAuthSecret is now two joined random UUIDs
1.1.1
- Small template modifications