This repository contains custom .NET templates based on bITdevKit (bIT DevKit) that follows the Onion Architecture principles. These templates help you quickly scaffold new solutions and modules following this architecture approach.
The solution template creates a complete solution structure with an initial module. It sets up the foundation for your application following Onion Architecture principles.
The module template helps you add new functional modules to your solution. Each module is structured following the Onion Architecture pattern with separate projects for different concerns.
Each module contains the following projects:
[ModuleName].Application.csproj[ModuleName].Domain.csproj[ModuleName].Infrastructure.csproj[ModuleName].Presentation.csproj[ModuleName].IntegrationTests.csproj[ModuleName].UnitTests.csproj
- .NET 9 SDK or later
To install the templates from NuGet.org:
dotnet new install BridgingIT.DevKit.TemplatesAfter installation, verify the templates are available:
dotnet new listYou should see:
bITdevKit Solution bdksolution [C#] Solution
bITdevKit Module bdkmodule [C#] Module
To update to the latest version:
# Uninstall current version
dotnet new uninstall BridgingIT.DevKit.Templates
# Install latest version
dotnet new install BridgingIT.DevKit.TemplatesTo create a new solution with an initial module:
dotnet new devkitsolution --SolutionName SolutionName --ModuleName Core --allow-scripts yes -o ./projects/SolutionNameParameters:
--SolutionName: The name of your solution (default: DevKit.Examples.GettingStarted)--ModuleName: The name of the initial module (default: Core)-o: Output directory for the solution
To add a new module to an existing solution:
cd ./projects/SolutionName
dotnet new bdkmodule --ModuleName ModuleName -o src/Modules/ModuleName --allow-scripts yesParameters:
--ModuleName: The name of the new module-o: Output directory for the module
After adding a new module, the template will automatically add the generated projects to your solution file.
Importannt: Some manual adjustments are required after adding a new module. Otherwise the new module will not be fully setup. Please follow the steps below.
- src\Presentation.Web.Server\Program.cs: Register the new module in the service configuration:
// ===============================================================================================
// Configure the modules
builder.Services.AddModules(builder.Configuration, builder.Environment)
// ...
.WithModule<[ModuleName]Module>() // add this manually
// ...- src\Presentation.Web.Server\appsettings.json: Add configuration section for the new module:
// ...
"Modules": {
// ...
"[ModuleName]": { // add this manually
"Enabled": true,
"ConnectionStrings": {
"Default": "ConnectionStringHere"
}
}
}The template creates a solution following Onion Architecture principles with the test projects included within the same directory as their corresponding implementation projects:
SolutionName/
├── src/
│ ├── Modules/
│ │ ├── ModuleName/
│ │ │ ├── ModuleName.Application/
│ │ │ ├── ModuleName.Domain/
│ │ │ ├── ModuleName.Infrastructure/
│ │ │ └── ModuleName.UnitTestPresentations/
│ └── Presentation.Web.Server/
├── tests/
│ └── ModuleName/
│ ├── ModuleName.IntegrationTests/
│ └── ModuleName.UnitTests/
└── SolutionName.slnx
| Template Name | Short Name | Description |
|---|---|---|
| bITdevKit Solution | bdksolution |
Creates a complete solution with initial module following Onion Architecture |
| bITdevKit Module | bdkmodule |
Adds a new module to an existing solution |
If you encounter any issues with the templates:
-
Templates not found after installation:
# Check if templates are installed dotnet new list # If not found, try reinstalling dotnet new install BridgingIT.DevKit.Templates --force
-
Permission errors during installation:
# On Linux/Mac, you might need sudo for global installation sudo dotnet new install BridgingIT.DevKit.Templates -
Outdated templates:
# Uninstall and reinstall to get latest version dotnet new uninstall BridgingIT.DevKit.Templates dotnet new install BridgingIT.DevKit.Templates
-
Missing .NET SDK:
- Make sure you have .NET 9 SDK or later installed
- Verify with:
dotnet --version
-
Projects not added to solution automatically:
# Add projects manually to solution dotnet sln YourSolution.sln add src/Modules/ModuleName/*.csproj
-
Template parameters not working:
# Check available parameters for a template dotnet new bdksolution --help dotnet new bdkmodule --help
-
Package not found:
- Ensure you have internet connection
- Check NuGet.org is accessible
- Try clearing NuGet cache:
dotnet nuget locals all --clear
-
Version conflicts:
# Install specific version if needed dotnet new install BridgingIT.DevKit.Templates::1.0.1-preview
To uninstall the templates:
dotnet new uninstall BridgingIT.DevKit.TemplatesFor developers who want to test templates locally from source:
# Clone the repository
git clone https://github.com/bridgingIT/bIT.devkit-examples-gettingstarted.git
cd bIT.bITdevKit.GettingStarted
# Reinstall templates from local source
dotnet new uninstall . | dotnet new install .
# Test template creation
dotnet new bdksolution --SolutionName TestSolution --ModuleName Core -o ../TestSolution --allow-scripts yes
cd ../TestSolution
dotnet new bdkmodule --ModuleName Administration -o src/Modules/Administration --allow-scripts yesYou can customize these templates by modifying the template configuration files:
- Solution template:
.template.config/template.jsonin the solution template directory - Module template:
src/Modules/CoreModule/.template.config/template.jsonin the module template directory - Post template scripts:
.bdk/template/post-action-*.ps1
For more information about .NET template development:
- GitHub Issues: Report issues or request features
- NuGet Package: BridgingIT.DevKit.Templates on NuGet.org
- Documentation: bITdevKit Documentation
This project is licensed under the MIT License - see the LICENSE file for details.