Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

dotnet new Templates

The Particular dotnet new templates makes it easier to bootstrap a variety of common project and code related scenarios.

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:

Once the package is installed, the template can be found in the Visual Studio New Project dialog:

NServiceBus endpoint template 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:

Customing endpoint properties in the additional information dialog

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

OptionDescription
-n,
--name
The name of the endpoint to create.
-f,
--framework
The target framework for the project.
One of: net8.0, net7.0 (default), net6.0, 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.

To create a message handler class that implements IHandleMessages<MyMessage>:

dotnet new nsbhandler --name ClassName --messagetype MyMessage

Options

OptionDescription
-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.

To create a saga:

dotnet new nsbsaga --name ClassName --messagetype1 Message1 --messagetype2 Message2

Options

OptionDescription
-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

Related Articles