How to create a new module in VC v3

How to create a new module for Virto Commerce Platform v3 from scratch? Follow the steps to create a “Dummy module”.

1. Create a well-structured solution and projects

  1. Create empty DummyModule solution:
  2. Add src and tests Solution Folders (using Visual Studio)
  3. In src add project using “Class library (.NET Core)” template:
    1. Project name: DummyModule.Core
    2. Location: …\DummyModule\src folder (create the missing src folder).
  4. Add DummyModule.Data and DummyModule.Web projects in the same way, just ensure they are located under src folder.
  5. Delete the auto-generated Class1.cs from all projects.
  6. In tests add project using “xUnit Test Project (.NET Core)” template:
    1. Project name: DummyModule.Tests
    2. Location: …\DummyModule\tests folder (create the missing tests folder).
  7. Set “Target framework” to “.NET Core 2.2” for all 4 projects.
  8. References to projects:
    1. DummyModule.Data: add reference to DummyModule.Core project
    2. DummyModule.Web: add references to DummyModule.Core, DummyModule.Data projects
    3. DummyModule.Tests: add references to DummyModule.Core, DummyModule.Data, DummyModule.Web projects
  9. References to NuGet packages:
    1. DummyModule.Core: add reference to latest version 3 (3.x) VirtoCommerce.Platform.Core package.
    2. DummyModule.Data: add reference to latest version 3 (3.x) VirtoCommerce.Platform.Data package.
  10. References to NuGet packages in VirtoCommerce.Platform.Web:
    1. (Double click in Visual Studio to) open DummyModule.Web.csproj file for editing;
    2. Add new ItemGroup:
      <PackageReference Include="Microsoft.AspNetCore.App" />
  11. Compile the solution (there should be no warnings).

2. DummyModule.Core

  1. ModuleConstants.cs (permissions, settings)
  2. Models
  3. Services
  4. Events
  5. Notifications

3. DummyModule.Data

  1. Models
  2. Repositories
    1. DbContext
    2. DesignTimeDbContextFactory,
    3. IRepository, Repository
  3. Migrations
  4. Caching
  5. Services
  6. ExportImport
  7. Handlers
  8. Search
  9. Authorization (resource based authorization). Sample:

4. DummyModule.Web

  1. module.manifest
  2. JsonConverters
  3. Module.cs
  4. API controllers
  5. Content
  6. Scripts
  7. webPack:
  8. Localizations

5. DummyModule.Tests

  1. Unit tests
  2. Integration tests

6. Pack the module (using VirtoCommerce.GlobalTool)

  1. dotnet tool install VirtoCommerce.GlobalTool -g --version 3.0.0-beta0008
  2. copy and edit .nuke
  3. vc-build compress