A comprehensive template for AI-driven C# development with full CI/CD pipeline support.
- .NET 8.0 support: Works with the latest .NET LTS version
- Cross-platform testing: CI runs on Ubuntu, macOS, and Windows
- Comprehensive testing: xUnit tests with coverage reporting
- Code quality: EditorConfig + .NET analyzers with warnings as errors
- Pre-commit hooks: Automated code quality checks before commits
- CI/CD pipeline: GitHub Actions with multi-platform support
- Changesets workflow: Version-safe changelog management (like JavaScript Changesets)
- Release automation: Automatic NuGet publishing and GitHub releases
- Click "Use this template" on GitHub to create a new repository
- Clone your new repository
- Update
src/MyPackage/MyPackage.csprojwith your package name and description - Rename the solution and project files as needed
- Update imports in tests and examples
- Build and start developing!
# Clone the repository
git clone https://github.com/link-foundation/csharp-ai-driven-development-pipeline-template.git
cd csharp-ai-driven-development-pipeline-template
# Build the project
dotnet build
# Run tests
dotnet test
# Run the example
dotnet run --project examples/BasicUsage# Run all tests
dotnet test
# Run tests with verbose output
dotnet test --verbosity normal
# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"
# Run a specific test
dotnet test --filter "FullyQualifiedName~CalculatorTests"# Format code
dotnet format
# Check formatting (CI style)
dotnet format --verify-no-changes
# Build with warnings as errors
dotnet build --configuration Release /warnaserror
# Check file size limits
bun run scripts/check-file-size.mjs
# Run all checks
dotnet format --verify-no-changes && dotnet build --configuration Release /warnaserror && bun run scripts/check-file-size.mjs.
├── .changeset/ # Changesets configuration
│ ├── config.json # Changeset settings
│ ├── README.md # Changeset instructions
│ └── *.md # Individual changesets
├── .github/
│ └── workflows/
│ └── release.yml # CI/CD pipeline configuration
├── examples/
│ ├── BasicUsage.cs # Usage example
│ └── BasicUsage.csproj # Example project
├── scripts/
│ ├── bump-version.mjs # Version bumping utility
│ ├── check-file-size.mjs # File size validation script
│ ├── create-github-release.mjs # GitHub release creation
│ ├── merge-changesets.mjs # Merge multiple changesets
│ ├── validate-changeset.mjs # PR changeset validation
│ └── version-and-commit.mjs # CI/CD version management
├── src/
│ └── MyPackage/
│ ├── Calculator.cs # Example implementation
│ ├── PackageInfo.cs # Package version info
│ └── MyPackage.csproj # Library project
├── tests/
│ └── MyPackage.Tests/
│ ├── CalculatorTests.cs # Test suite
│ ├── PackageInfoTests.cs # Package info tests
│ └── MyPackage.Tests.csproj # Test project
├── .editorconfig # Code style configuration
├── .gitignore # Git ignore patterns
├── .pre-commit-config.yaml # Pre-commit hooks configuration
├── Directory.Build.props # Shared build properties
├── MyPackage.sln # Solution file
├── CHANGELOG.md # Project changelog
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # Unlicense (public domain)
└── README.md # This file
-
EditorConfig: Consistent code style across all editors
- Enforces naming conventions, formatting, and style rules
- Integrated with .NET analyzers
-
.NET Analyzers: Built-in static analysis
- All warnings treated as errors
- Latest analysis level enabled
- Enforces best practices
-
Pre-commit hooks: Automated checks before each commit
- Runs dotnet format to ensure formatting
- Builds with warnings as errors
- Runs tests to prevent broken commits
The template supports multiple levels of testing:
- Unit tests: In
tests/MyPackage.Tests/using xUnit - Theory tests: Data-driven tests with
[Theory]and[InlineData] - Coverage: Automatic collection with Coverlet
- Examples: In
examples/directory (also serve as documentation)
This template uses a changesets workflow similar to Changesets in JavaScript:
Benefits:
- No merge conflicts: Multiple PRs can add changesets independently
- Version safety: Version bumps happen after PR merge, not before
- Per-PR documentation: Each PR documents its own changes
- Automated releases: Changesets are collected and processed automatically
# Create a changeset file
cat > .changeset/my-change.md << 'EOF'
---
'MyPackage': patch
---
Description of your changes
EOFVersion types:
major- Breaking changes (1.x.x -> 2.0.0)minor- New features (x.1.x -> x.2.0)patch- Bug fixes (x.x.1 -> x.x.2)
The GitHub Actions workflow provides:
- Changeset validation: Ensures PRs include a changeset file
- Linting: dotnet format and build with warnings as errors
- Test matrix: 3 OS (Ubuntu, macOS, Windows) with .NET 8.0
- Building: Release build and package validation
- Release: Automated versioning, NuGet publishing, and GitHub releases
The release workflow supports two modes:
Automatic Release (on push to main):
- Detects changesets in
.changeset/directory - Merges multiple changesets if needed (using highest bump type)
- Updates version in csproj and CHANGELOG.md
- Creates git tag and pushes changes
- Publishes to NuGet and creates GitHub release
Manual Release (via workflow_dispatch):
instantmode: Immediate version bump and releasechangeset-prmode: Creates a PR with changeset for review
After creating a repository from this template:
-
Update
src/MyPackage/MyPackage.csproj:- Change
PackageIdfield - Update
RepositoryUrl - Change description and authors
- Change
-
Rename the solution and project files:
MyPackage.slnsrc/MyPackage/tests/MyPackage.Tests/
-
Update project references in:
examples/BasicUsage.csprojtests/MyPackage.Tests/MyPackage.Tests.csproj
-
Update imports in source files
Code style is configured in .editorconfig. Current configuration:
- 4-space indentation for C# files
- LF line endings
- File-scoped namespaces
- Expression-bodied members preferred
- var preferred where type is apparent
Analyzers are configured in Directory.Build.props:
- All warnings treated as errors
- Latest analysis level enabled
- .NET analyzers enabled
- Code style enforcement in build
| Script | Description |
|---|---|
dotnet test |
Run all tests |
dotnet format |
Format code |
dotnet build /warnaserror |
Build with strict warnings |
dotnet run --project examples/BasicUsage |
Run example |
bun run scripts/check-file-size.mjs |
Check file size limits |
bun run scripts/bump-version.mjs |
Bump version |
using MyPackage;
// Basic arithmetic
var sum = Calculator.Add(2, 3); // 5
var product = Calculator.Multiply(2, 3); // 6
Console.WriteLine($"2 + 3 = {sum}");
Console.WriteLine($"2 * 3 = {product}");
// Async operations
await Calculator.DelayAsync(1.0); // Wait for 1 secondSee examples/BasicUsage.cs for more examples.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and add tests
- Run quality checks:
dotnet format && dotnet build /warnaserror && dotnet test - Add a changeset file in
.changeset/ - Commit your changes (pre-commit hooks will run automatically)
- Push and create a Pull Request
Unlicense - Public Domain
This is free and unencumbered software released into the public domain. See LICENSE for details.
Inspired by: