Skip to content

Project templates

Nikolay Pianikov edited this page Jul 22, 2024 · 8 revisions

NuGet

Pure.DI provides project templates to set up your DI-based project easily. The template exists for the C# language.

How to install the templates

The templates require the .NET SDK. Run the following command to install Pure.DI templates for dotnet new:

dotnet new install Pure.DI.Templates

If you want to uninstall templates:

dotnet new uninstall Pure.DI.Templates

Basic usage

To create a new C# DI-based console project from the template, run:

dotnet new di

After that, you can run the created application:

dotnet run

Project template specific options

By default, a console application project targeting net5.0 is created. You can specify -f or --framework to change a targeting framework:

dotnet new di -f netcoreapp3.1

The option --classlib creates a class library app project targeting netstandard2.0 by default:

dotnet new di --classlib

The option -c or --composerName sets the name of the "composer" class:

dotnet new di -c ClockDomain

By default, a create projects resolve to the highest acceptable stable version of Pure.DI. You can specify this version manually by the option _-v or --version:

dotnet new di -v 1.1.27

Use the -h or --help option to display all possible arguments with a description and the default values:

dotnet new di --help

Templates list

  • di - creates a simple console application
  • dilib - creates a class library using Pure.DI, which can be used as a binary dependency from the NuGet package or as a source code dependency as a reference to a project
Clone this wiki locally