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: https://docs.microsoft.com/en-us/visualstudio/get-started/tutorial-projects-solutions?view=vs-2019##create-a-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:
    <ItemGroup>
      <PackageReference Include="Microsoft.AspNetCore.App" />
    </ItemGroup>
    
  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: https://github.com/VirtoCommerce/vc-module-store/tree/release/3.0.0/src/VirtoCommerce.StoreModule.Data/Authorization

4. DummyModule.Web

  1. module.manifest
  2. JsonConverters
  3. Module.cs
  4. API controllers
  5. Content
  6. Scripts
  7. webPack: https://github.com/VirtoCommerce/vc-module-order/blob/release/3.0.0/src/VirtoCommerce.OrdersModule.Web/webpack.config.js
  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
2 Likes

vc-buid compress delete the localization folder so it’s not picking up the value so how to resolve this ?

Did you use latest version fo vc-build?
Did you add localizaion file to project?

Could you share with us your source code? We will check what’s wrong.

Most of the VC modules has localization file, like Catalog Module and we use Virto Commerce CLI (vc-build) to create package.

image

Latest actual version you can find in Developer guide - Create a new module - Virto Commerce Documentation

Hi
this issue is resolved when we change the localization file name file name was en.PrescriptionModule.json but module name is NB.PrescsriptionModule so we change the name of localization file name to en.NB.PrescriptionModule.json after changing the name it was resolved

Thanks

1 Like