|
Default files for C# projects
A script that build a modular .NET solution following Clean Architecture principles, supporting standalone, local network, and cloud deployments. The system separates domain, application, and infrastructure layers, and is designed for maintainability, testability, and scalability.
|
This repository provides a template for initializing .NET projects with default files and a setup script. It is designed to help developers quickly scaffold a new solution following Clean Architecture principles, including recommended folder structure, configuration, and build scripts.
Dotnet.DefaultFiles serves as a starting point for .NET development. It includes:
mkdir MyNewSolution)cd MyNewSolution)solution-structure.config.yaml) to define the directory and file structure, which is loaded by import-yaml-config.ps1:This will create the recommended folder structure, add default files, and configure the solution for Clean Architecture, all based on the YAML configuration.
The folder structure will be created as follows:
The setupSolutionCleanArchentectureCSharp.ps1 script supports several arguments to customize the solution setup:
Arguments:
| Switch | Description |
|---|---|
-Files | Only create directories, hardlink, and copy default files. |
-Arch | Only set up Clean Architecture solution and projects (Domain, Application, Infrastructure). |
-Blazor | Set up Clean Architecture and add Blazor WebAssembly and server projects (frontend/backend) |
-WebApi | Set up Clean Architecture and add a Web API project |
-Help | Show usage instructions and exit. |
-DefaultFilesRoot <path> | Optional path to a custom source for default files. |
-SolutionFile <file> | Optional custom solution file name. |
-Framework <version> | Optional .NET target framework (default: net10.0). |
Examples:
global.json, Directory.Build.props).global.json: .NET SDK version managementDirectory.Build.props / Directory.Build.targets: Solution-wide build settings.gitignore: Standard ignore rulesnuget.config: Custom NuGet feedsThe ci-cd.ps1 script automates essential CI/CD safety and consistency checks for your repository. It ensures:
main branch.Using this script helps maintain a clean, reliable, and reproducible development and deployment workflow, especially in collaborative or cross-platform environments.
main branch.Note:
For more details, see the comments in ci-cd.ps1.
The .github directory contains configuration, automation, and documentation resources that support development workflows and code quality:
.github/copilot-instructions.md defines repository-wide rules for Copilot agents, including Clean Architecture conventions, folder structure, and documentation standards..github/instructions/ contains detailed instructions and prompts for Copilot agents, such as how to generate or validate domain models, documentation, and code artifacts.dm-artifact.agent.md) provide reusable templates for generating domain model documentation and other artifacts.These resources ensure consistency, automate repetitive tasks, and provide guidance for both humans and AI agents working in the repository.
For more details, see the .github/ directory and referenced documentation.
src/, tests in tests/.README.md with any new setup or usage instructions.For more details, see the Microsoft documentation and Clean Architecture guides.
To enable CI/CD with the provided workflow, you must configure the following repository secrets in your GitHub project:
| Secret Name | Description | Example Value |
|---|---|---|
DB_HOST | Database server host (PostgreSQL/MySQL/other) | localhost or db.example |
DB_PORT | Database server port | 5432 (Postgres default) |
DB_NAME | Database name | mydatabase |
DB_USER | Database user | dbuser |
DB_PASSWORD | Database user password | supersecret |
TOKENVALIDATIONPARAMETERS__ISSUERSIGNINGKEY | JWT signing key for token validation | your-signing-key |
How to add secrets:
Settings > Secrets and variables > Actions.New repository secret for each secret above and enter the name and value.These secrets are used by the workflow in .github/workflows/ci.yml to generate the .env file and configure your build and test environment.
If you use GitHub Pages to publish documentation or a project site, you can add a google*.html file (such as googleXXXX.html) for Google site verification. This file is used by Google Search Console or Analytics to collect statistics about your site.
How to add Google verification:
googleXXXXXXXXXXXX.html).shared/github-pages/ folder.This is useful for tracking site traffic, indexing, and using other Google webmaster tools with your GitHub Pages site.
The repository also includes Copilot agents, instructions and prompts to assist developers in generating artifacts, code and documentation. These resources can be found in the .github/ directory and are designed to enhance productivity and ensure consistency across projects.
Generates, validates, and maintains domain model (DM) documentation in markdown, following strict content, structure, and naming conventions for clarity and consistency. It analyses business case, identifies domain entities and relationships, and produces DM artifacts that align with the projectβs domain language and requirements. The agent ensures that DM files are correctly named, versioned, and structured according to the instructions, and it validates the content for completeness and clarity without evaluating quality criteria.
Example Usage:
Distributed under the AGPL-3.0 License.
Jens Tirsvad Nielsen - LinkedIn