Provides the ability to generate an entire API Solution project including:
- API Project
- Unit & Integration test projects
- Github Action or Bitbucket Pipeline configuration
- Dotnet Cake Build Script
- Semantic Versioning
- Docker Configuration
To create a new solution using the
apisolution template simply open a terminal window and execute the command with the supplied parameters below in chosen directory
dotnet new apisolution --name <name of your solution> --root <your chosen root namespace>
--nameIs a name switch that is used to provide your project a name for instance Cms
--rootis a root namespace you would like to use for your project i.e. Your company name or some such.
As an example we may want to develop the Diogel project for our company Threenine with so you can execute the command as follows:
dotnet new apisolution --name Diogel --root Threenine
This command will generate a full API Solution template
. ├── bitbucket-pipelines.yml ├── build.cake ├── Diogel.sln ├── Directory.Build.props ├── docker-compose.yml ├── Dockerfile ├── .github │ └── workflows │ └── cake-build.yaml ├── .gitignore ├── GitVersion.yml ├── README.md ├── src │ ├── Api │ │ ├── Activities │ │ ├── Api.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Behaviours │ │ ├── Exceptions │ │ ├── Helpers │ │ ├── Middleware │ │ ├── Program.cs │ │ ├── Properties │ │ └── README.md │ ├── Database │ │ ├── appsettings.json │ │ ├── DiogelContext.cs │ │ ├── DiogelContextFactory.cs │ │ ├── Configurations │ │ ├── Database.csproj │ │ └── README.md │ ├── DTOs │ │ ├── Dto1.cs │ │ └── DTOs.csproj │ └── Models │ ├── Cmss │ └── Models.csproj └── tests ├── Integration │ ├── Asserts │ ├── Integration.csproj │ └── Tests └── Unit └── Unit.csproj
This will generate a full API Solution stub containing the typical project configuration for your solution. Enabling you to focus on the aspects of your project that really add value.
From the outset the API Solution template, is ready for you to start your development projects and you can start coding and implementing the business value required. However, there is one step that is required before getting started with your coding tasks - which is setting up your version control.
By convention, a vast majority of software developers predominantly make use of Git - Version Control.
The API solution makes use of Semantic Versioning and makes use of GitVersion which requires a Git Repository, so all you create a Git Repository by Changing into the root of your created directory and using:
The API template Pack, takes an opinionated view, on defining PostgreSQL as the default database to base API’s from. We have detailed the number of reasons why we chose PostgreSQL as the default database option. As such we we included a Docker-compose script that will setup a local PostgreSQL database for you.
You can open the Solution file in any IDE (Intergrated Development Environment) that supports Dotnet Solution files this includes some of the most preferred editors in the Dotnet Community including:
- Rider - Fast & powerful cross-platform .NET IDE
- Visual Studio 2022 IDE - Programming Tool for Software Developers
- Visual Studio Code
The image below is a screen shot of the Solution we created open in Rider
All you need to do to get this up and running is to execute the command
docker-compose up -d in the root directory of your project. Alternatively, if you are using Rider you can learn How to run docker compose files in Rider
- What is this Directory.Build.props file all about?
- How to use Cake with Github Actions
- How to run docker compose files in Rider