A C# Console Application for generating Class Libraries based on the Onion Architecture and automatically adding them to your .sln
file. This tool simplifies project setup and enforces a clean architectural structure.
Anion is derived from the combination of the words "Auto" and "Onion" and refers to the automated construction of the onion architecture structure in Asp.NET Core.
This project automates the creation of Onion Architecture layers for your .NET solution. It creates Class Library projects, adds references between them, and integrates them into your .sln
file. The generated structure supports scalable, maintainable, and testable applications.
- Automatically generates the following layers:
Common
Data
Entities
IoCConfig
Services
ViewModels
- Adds project references between layers based on dependency rules.
- Seamlessly integrates all Class Libraries into the existing solution file.
Before using this tool, ensure you have the following installed:
- .NET SDK (minimum version 5.0 - Built it on 8.0)
#verify using dontnet --version
- Visual Studio or another IDE for .NET development
- A
.sln
file in your project's root directory
git clone https://github.com/pezhvak98/Anion.git
cd Anion
Open the solution file in Visual Studio or build using the CLI:
dotnet build
Use this command to release package to use it Globally in your system :
dotnet pack -c Release
After the package is released, a folder named bin
is created in the same path as the main package file in the Release
folder. You should use that file to install the package:
dotnet tool install --global --add-source ./bin/Release Anion
After building the project through Visual Studio, either using CMD outside of Visual Studio or the Package Manager Console in Visual Studio, by running the following command, all the built files and references are added to each.
Anion --Generate
Note: When you run this command, a new window will open and give you a warning about reloading the solution. You must click the Reload button after the tool finishes. If you click it while the tool is running, Visual Studio will not be able to automatically recognize the new files and you will have to manually add each of the projects from the path
Right click on Solution > Add > Existing Project > Select project
.
Example Output:
Created: ../YourProject.Common
Created: ../YourProject.Data
...
Onion architecture Class Libraries created and added to the solution successfully.
IMPORTANT: Please click 'Reload' in Visual Studio when prompted to apply changes.
It is recommended that after the tool finishes and reloads the project, create a folder called
src
and place all the layers in it so that your project is better managed than before.
If for any reason you decide to remove this tool, you can remove it globally by simply running the following command:
dotnet tool uninstall --global Anion
The following Class Library layers will be created:
-
Common
Shared components like constants, enums, and utility classes. -
Data
Data access layer for interacting with databases. -
Entities
Defines the domain entities. -
IocConfig
Handles Dependency Injection configurations. -
Services
Contains business logic services. -
ViewModels
Contains data models used for presentation.
Inspired by the principles of Onion Architecture in .Net Core.