Environment Setup
Requirements
Section titled “Requirements”1. .NET 10.0 SDK
Section titled “1. .NET 10.0 SDK”# Check versiondotnet --version# Example output: 10.0.100
# Install (Windows)winget install Microsoft.DotNet.SDK.10
# Install (macOS)brew install --cask dotnet-sdk
# Install (Linux - Ubuntu)sudo apt-get update && sudo apt-get install -y dotnet-sdk-10.02. IDE Setup
Section titled “2. IDE Setup”VS Code + C# Dev Kit
Section titled “VS Code + C# Dev Kit”- Install the C# Dev Kit extension
JetBrains Rider
Section titled “JetBrains Rider”- .NET 10.0 SDK is automatically detected
- Verify the SDK path in File -> Settings -> Build, Execution, Deployment -> Toolset and Build
Visual Studio 2022
Section titled “Visual Studio 2022”- Visual Studio 2022 version 17.12 or later recommended
- Workloads: ”.NET desktop development” or “ASP.NET and web development”
Project Setup
Section titled “Project Setup”Clone Source Code
Section titled “Clone Source Code”# Clone the Functorium projectgit clone https://github.com/hhko/Functorium.gitcd functoriumVerify Build
Section titled “Verify Build”# Build the entire solutiondotnet build Functorium.slnx
# Run all testsdotnet test --solution Functorium.slnxRun Individual Projects
Section titled “Run Individual Projects”# Run tests for Part 1 first chapterdotnet test --project Docs.Site/src/content/docs/tutorials/cqrs-repository/Part1-Domain-Entity-Foundations/01-Entity-And-Identity/EntityAndIdentity.Tests.Unit
# Build/test the entire tutorialdotnet build Docs.Site/src/content/docs/tutorials/cqrs-repository/cqrs-repository.slnxdotnet test --solution Docs.Site/src/content/docs/tutorials/cqrs-repository/cqrs-repository.slnxDefault Using Statements
Section titled “Default Using Statements”These are the default using statements used in the projects:
// Domain entitiesusing Functorium.Domains.Entities;
// Repositoryusing Functorium.Domains.Repositories;
// Query adapterusing Functorium.Applications.Queries;
// Usecaseusing Functorium.Applications.Usecases;
// Specificationusing Functorium.Domains.Specifications;When using LanguageExt functional types:
using LanguageExt;using LanguageExt.Common;using static LanguageExt.Prelude;Running Each Project
Section titled “Running Each Project”Running Tests
Section titled “Running Tests”# Run tests for a specific projectdotnet test --project Docs.Site/src/content/docs/tutorials/cqrs-repository/Part1-Domain-Entity-Foundations/01-Entity-And-Identity/EntityAndIdentity.Tests.Unit
# Run a specific testdotnet test --filter "Create_ReturnsAggregate_WhenValid"Running All Solution Tests
Section titled “Running All Solution Tests”# From the solution rootdotnet test --solution Functorium.slnxProject Structure
Section titled “Project Structure”Each tutorial project follows this structure:
01-Entity-And-Identity/├── EntityAndIdentity/ # Main project│ ├── EntityAndIdentity.csproj # Project file│ └── Domains/ # Domain classes│ ├── Product.cs│ └── ProductId.cs│└── EntityAndIdentity.Tests.Unit/ # Test project ├── EntityAndIdentity.Tests.Unit.csproj ├── xunit.runner.json └── ProductTests.csFunctorium Dependencies
Section titled “Functorium Dependencies”Each project references the Functorium library. It is configured in the project file as follows:
<ItemGroup> <ProjectReference Include="../../../../../../../../../Src/Functorium/Functorium.csproj" /></ItemGroup>Key CQRS-related types provided by Functorium:
| Namespace | Key Types | Purpose |
|---|---|---|
Functorium.Domains.Entities | Entity<TId>, AggregateRoot<TId>, IEntityId | Domain entities |
Functorium.Domains.Repositories | IRepository<TAggregate, TId> | Command-side Repository |
Functorium.Applications.Queries | IQueryPort<TEntity, TDto> | Query-side adapter |
Functorium.Applications.Usecases | ICommandRequest, IQueryRequest | Usecase interfaces |
Functorium.Applications.Persistence | IUnitOfWork, IUnitOfWorkTransaction | Persistence |
Troubleshooting
Section titled “Troubleshooting”.NET SDK Not Recognized
Section titled “.NET SDK Not Recognized”# Check PATH environment variableecho $PATH
# On Windows, add the following path to system environment variables# C:\Program Files\dotnetIntelliSense Not Working in IDE
Section titled “IntelliSense Not Working in IDE”- Restart the IDE
- Run
dotnet restore - Delete the
.vsor.vscodefolder and restart
LanguageExt Build Errors
Section titled “LanguageExt Build Errors”Verify that the LanguageExt.Core package has been properly restored:
dotnet restoredotnet buildQ1: Can I use an earlier version instead of .NET 10.0 SDK?
Section titled “Q1: Can I use an earlier version instead of .NET 10.0 SDK?”A: The projects in this tutorial target .NET 10.0. Some LanguageExt and Functorium APIs may not be compatible with earlier versions, so installing the .NET 10.0 SDK is recommended.
Q2: Can I test individual projects without building the entire solution?
Section titled “Q2: Can I test individual projects without building the entire solution?”A: Yes, running dotnet test from each chapter’s test project folder will build/test only that project. Building the entire solution is used to verify consistency across all projects.
Q3: What should I do if LanguageExt build errors occur?
Section titled “Q3: What should I do if LanguageExt build errors occur?”A: First, restore packages with dotnet restore. If that doesn’t resolve it, delete the bin and obj folders and rebuild. Also verify that the LanguageExt.Core package downloads correctly from the NuGet source.
With the environment setup complete, it’s time to understand the overall structure of the CQRS pattern.