(2) Part 2 of Introduction to MasaFramework: Install MasaFramework to understand various templates

(2) Part 2 of Introduction to MasaFramework: Install MasaFramework to understand various templates

Install MasaFramework to understand each template

最后更新 3/25/2023 7:43 PM
token的技术分享
预计阅读 5 分钟
分类
.NET
标签
.NET C# MASA Framework

Install MasaFramework templates

Execute the following command to install the latest Masa template

dotnet new install Masa.Template

Four templates will appear after installation is completed

Masa Blazor App

The Masa Blazor App template creates a project template that does not carry a solution. The default project structure is as shown in the figure:

A simple Masa Blazor Server project.

Masa Blazor Pro Web

There are many types of template creation for Masa Blazor Pro Web:

  • Wasm is a pure Wasm model.
  • Wasm-Host is to start a Server hosting Wasm.
  • Wasm-PWA supports browser installation.
  • Server is a pure Blazor Server model.
  • ServerAndWasm provides a razor class library as an interface, supporting both Blazor Server and Blazor Wasm modes.

The fifth mode is recommended for the above five modes, so that you can deploy Blazor Server and Blazor Wasm modes during deployment, allowing users to switch by themselves. Analyze the following Masa Blazor Pro Web project structure:

The MasaWebPro1 project is a Razor class library that provides interface logic and actual business.

The MasaWebPro1.Server project is just the interface to host the MasaWebPro1 project in Blazor Server mode.

The MasaWebPro1.WebAssembly project is just an interface for hosting the MasaWebPro1 project in Blazor WebAssembly model.

Running the project will get a beautiful project template:

You can conduct secondary development of its modifications, or you can combine Pro and MasaFramework.

Masa Blazor Website

Masa Blazor Website project structure:

Masa Blazor Website is a template for an older version of the document site. To briefly describe it, globalization is used by default.

Masa Framework Project

The Masa Framework Project is our protagonist.

Comrades who need to use the MasaFramework need to create this template. Previous templates were all pure Blazor.

There were multiple options when we created the MasaFramework:

  • Use Controllers: Do not use MiniApis after using the controller to enable it (MiniApis more recommended)
  • Enable OpenAPI Support: Is Swagger actually used by default
  • Add Dapr Support: Add support for Dapr
  • Use Dapr Actor: Use Dapr Actor
  • Add Authorization An Authentication: Add authorization and authentication
  • Add Fluent Validation Middleware: Add verification middleware

Let's explain the four project templates of Choice Add Service Project and Mode: Basic, Cqrs, Ddd, and Cqrs&Ddd. Choice Add Web Project is actually Blazor's hosting model:

Basic:

A basic MasaFramework project structure.

Cqrs:

MasaFramework's Cqrs structure is somewhat different from the basic MasaFramework project.

Tips: CQRS (Command Query Responsibility Segregation) is an architectural pattern that separates read operations and write operations. The basic idea of CQRS is to separate read and write operations, which optimizes system performance and scalability. CQRS also provides a simple way to implement event-driven architecture, which makes systems more flexible and scalable.

Ddd:

The differences between MasaFramework's Ddd project and the basic template are also obvious.

Little knowledge: DDD (Domain Driven Design) is a software development methodology that emphasizes putting business domain concepts and business rules first rather than technical implementation when designing applications. The goal of DDD is to enable developers to better understand and implement complex business requirements.

Cqrs&Ddd:

Cqrs&Ddd integrates the features of both Cqrs and Ddd project templates and is a slightly complex framework.

Little knowledge: DDD and CQRS are often used together because they have the same goal: to put concepts and business rules in the business domain first, and to put technical implementation second. When using DDD and CQRS, developers often separate business logic from data access logic to better manage code and maintain the system.

DDD and CQRS are two different methodologies, but they both emphasize putting business requirements first and technical implementation second. If you are developing complex applications, using DDD and CQRS may help you.

project uses

If you want to use MasaFramework, you can combine Masa Pro templates with MasaFramework templates:

This is the project I currently use MasaFramework. The Web embeds Pro templates and modifies them. The current project is still improving. This is also the first project I have exposed to MasaFramework practice, because it meets my needs, is small in size, and has less dependence.

end

Sharing of token

Technical exchange group: 737776595

MasaFramework 学习地址:MASA Framework

Keep Exploring

延伸阅读

更多文章
同分类 / 同标签 4/22/2026

Support for. NET by operating system versions (250707 update)

Use virtual machines and test machines to test the support of each version of the operating system for. NET. After installing the operating system, it is passed by measuring the corresponding running time of the installation and being able to run the Stardust Agent.

继续阅读