The Particular dotnet new templates makes it easier to bootstrap a variety of common project and code related scenarios.
The dotnet new
command creates a new project, configuration file, or solution based on the specified template. The command provides a convenient way to initialize a valid SDK-style project. The command calls the template engine to create the artifacts on disk based on the specified template and options. More information is available in the dotnet-new documentation.
Installation
Install using the following command:
dotnet new install ParticularTemplates
NServiceBus Endpoint
The nsbendpoint
template will create a C# project for an NServiceBus endpoint. By selecting options, the endpoint is preconfigured with choices of:
- Target framework
- Message transport
- Data persistence
- Hosting model, which can be one of:
- Console Application
- Windows service hosting
- Docker container hosing
Once the package is installed, the template can be found in the Visual Studio New Project dialog:
After naming the project and selecting a location for it on disk, the Additional information screen will allow customizing the template:
Command-line usage
The default usage will create a Console Application using Learning Transport, Learning Persistence:
dotnet new nsbendpoint --name MyEndpoint [options]
dotnet sln add "MyEndpoint/MyEndpoint.csproj"
Parameters allow the selection of message transport, data persistence, and hosting model, including Windows Service or Docker container hosting.
Options
Option | Description |
---|---|
-n ,--name | The name of the endpoint to create. |
-f ,--framework | The target framework for the project. One of: net8. , net7. (default), net6. , net48 , net472 |
-t ,--transport | The message queue (transport) to use. One of LearningTransport (default), AzureServiceBus , AzureStorageQueues , SQS , RabbitMQ , SQL . |
-p ,--persistence | Where to store data. This should be the same place business data is stored. One of LearningPersistence (default), MSSQL , MySQL , PostgreSQL , Oracle , CosmosDB , AzureTable , RavenDB , MongoDB , DynamoDB |
-hm ,--hosting | The hosting model to use. One of: ConsoleApp (default), WindowsService , Docker |
For more details on available options and choices, use this command to get help:
dotnet new nsbendpoint --help
NServiceBus Handler
The nsbhandler
item template will create a C# class for a message handler.
Currently, Visual Studio does not support using item templates from the New Item dialog.
To create a message handler class that implements IHandleMessages
:
dotnet new nsbhandler --name ClassName --messagetype MyMessage
Options
Option | Description |
---|---|
-n ,--name | The name of the message handler class to create. |
-mt ,--messagetype | The message type for the handler to implement. Default: MessageType |
For more details on available options and choices, use this command to get help:
dotnet new nsbhandler --help
NServiceBus Saga
The nsbsaga
item template will create a C# class for a saga that includes the saga class, saga data class, handlers for two message types, a custom timeout class, and the ConfigureHowToFindSaga
method.
Currently, Visual Studio does not support using item templates from the New Item dialog.
To create a saga:
dotnet new nsbsaga --name ClassName --messagetype1 Message1 --messagetype2 Message2
Options
Option | Description |
---|---|
-n ,--name | The name of the saga class to create. |
-mt2 ,--messagetype | The first message type that will be handled by the saga. Default: MessageType1 |
-mt1 ,--messagetype | The second message type that will be handled by the saga. Default: MessageType2 |
For more details on available options and choices, use this command to get help:
dotnet new nsbsaga --help