Skip to content
Last update: February 11, 2025

Custom Modules Templates for Dotnet New

In this guide, we will learn how to create own custom module using dotnet new templates for Virto Commerce modules. This feature allows you to create a Virto Commerce module with a pre-configured entity, simplifying the development and integration of new components.

Template Name Description
vc-module-dba-xapi Creates a new Virto Commerce module with DB Agnostic and xAPI support.
vc-module-dba Creates a new Virto Commerce module with DB Agnostic support.
vc-module-xapi Creates a new Virto Commerce module with xAPI support.
vc-crud Creates all the classes needed for CRUD operations.

video tutorial

Install

To install the templates, run:

dotnet new install VirtoCommerce.Module.Template

Create new module from template

To create new module:

  1. Open Windows PowerShell console.
  2. Navigate to your sources folder.
  3. Run one of the following commands depending on the type of module you want to create:

    dotnet new vc-module-dba-xapi --ModuleName CustomerReviews --Author "Jon Doe" --CompanyName VirtoCommerce
    
    dotnet new vc-module-dba --ModuleName CustomerReviews --Author "Jon Doe" --CompanyName VirtoCommerce
    
    dotnet new vc-module-xapi --ModuleName CustomerReviews --Author "Jon Doe" --CompanyName VirtoCommerce
    

    Parameters

    Options Description Type Required Default value
    --Author (or -A) Your name string Optional John Doe
    --CompanyName (or -C) Your company name string Optional VirtoCommerce
    --ModuleName (or -M) Your module name string Optional NewModule
    --ModuleVersion Your module version string Optional 3.800.0
    --PlatformVersion (or -P) Virto Commerce platform version string Optional 3.876.0
    --CoreVersion Virto Commerce Core module version string Optional 3.800.0
    --XapiVersion (or -X) XAPI module version string Optional 3.901.0
  4. A vc-module-customer-reviews folder with module solution has been created.

Info

You can pass PlatformVersion attribute to create a new module for specific version of Virto Commerce.

Create CRUD classes from template

To create CRUD classes from template, run the following command:

dotnet new vc-crud --EntityName FooBar --CompanyName VirtoCommerce --ModuleName CustomerReviews

Parameters

Options Description Type Required Default value
--CompanyName (or -C) Your company name string Optional VirtoCommerce
--ModuleName (or -M) Your module name string Optional NewModule
--EntityName (or -E) New entity name string Optional FooBar

It will create a folder called vc-module-customer-reviews with models, events, and services needed for CRUD operations. The company name and the module name are used to create the namespace for new classes.

Note

You can simply copy most of these files into your module, but you will need to merge new DbContext.cs, Repository.cs, and Module.cs files with existing ones.

Uninstall

To uninstall templates, run:

dotnet new uninstall VirtoCommerce.Module.Template

Contribute

To improve and extend the module creation process, contribute to the dotnet new templates by:

Install templates locally

To install templates locally:

  1. Open Windows PowerShell console
  2. Clone repository

    git clone https://github.com/VirtoCommerce/vc-cli-module-template
    
  3. Install downloaded templates:

    dotnet new install vc-cli-module-template\templates
    

Uninstall locally installed templates

To uninstall locally installed templates, run:

dotnet new uninstall <full or relative path to the templates directory>