'How can I create custom templates folders in C#?
In theses days I trying to use onion architecture with dotnet core and mediatr library. it's very tedious for me writing code for each use case. I have 8 entities and writing a crud for each entity. I have to create 32 use cases. For this reason, i want to create a command that it write the 4 use case in the crud per each entity.
Similar to this
Dotnet create crud user
And the response command will be like theses
User
|-create
..| cretaeUserRequest.cs
..| cretaeUserHandler.cs
..| cretaeUserResponse.cs
..| cretaeUserRequestValidator.cs
|-read
..| ReadUserRequest.cs
..| ReadUserHandler.cs
..| ReadUserResponse.cs
|-update
..| UpdateUserRequest.cs
..| UpdateUserHandler.cs
..| UpdateUserResponse.cs
..| UpdateeUserRequestValidator.cs
|-delete
..| deleteUserRequest.cs
..| deleteUserHandler.cs
..| deleteUserResponse.cs
..| deleteUserRequestValidator.cs
Each file have a template.
Solution 1:[1]
Official Microsoft guideline, if you follow Create a project template for dotnet.
https://docs.microsoft.com/en-us/dotnet/core/tutorials/cli-templates-create-project-template
After that look at the create a template package.
https://docs.microsoft.com/en-us/dotnet/core/tutorials/cli-templates-create-template-package
Both links has also a GitHub sample:
https://github.com/dotnet/samples/tree/main/core/tutorials/cli-templates-create-item-template
That will help you achieve your goal.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maytham Fahmi |
