A modern .NET 9 class library template with best practices built-in.
This is a GitHub template repository. Click the "Use this template" button to create your own repository based on this template.
- .NET 9 SDK or later
- Visual Studio Code (recommended) or Visual Studio 2022+
- Node.js (for MCP servers)
-
Create your repository from this template
- Click "Use this template" button on GitHub
- Name your repository
- Clone it locally
-
Rename the library
- Replace
YourLibrarywith your library name in:- Solution file:
YourLibrary.sln→YourProjectName.sln - Project files:
src/YourLibrary/→src/YourProjectName/ - Test files:
tests/YourLibrary.Tests/→tests/YourProjectName.Tests/ - Update namespaces in
.csfiles - Update project references in
.csprojfiles - Update
.vscode/settings.jsonand.vscode/tasks.json
- Solution file:
- Replace
-
Install MCP servers (for AI-assisted development)
.\scripts\install-mcps.ps1 -
Open in VS Code
code .
-
Build the solution
dotnet build
-
Run tests
dotnet test
YourLibrary/
├── .github/
│ └── instructions/ # AI assistant instructions
│ ├── base.instructions.md
│ └── cs.instructions.md
├── .vscode/ # VS Code configuration
│ ├── extensions.json # Recommended extensions
│ ├── launch.json # Debug configurations
│ ├── settings.json # Workspace settings
│ └── tasks.json # Build tasks
├── docs/ # Documentation
│ └── api/ # API documentation
├── scripts/ # Utility scripts
│ └── install-mcps.ps1 # MCP installation script
├── src/
│ └── YourLibrary/ # Main library project
│ ├── YourLibrary.csproj
│ └── Class1.cs
├── tests/
│ └── YourLibrary.Tests/ # Test project
│ ├── YourLibrary.Tests.csproj
│ ├── UnitTests/ # Unit tests (no external dependencies)
│ └── IntegrationTests/ # Integration tests (with external dependencies)
├── .editorconfig # Code style configuration
├── .gitignore # Git ignore rules
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # License file
├── mcp.json # MCP server configuration
├── README.md # This file
└── YourLibrary.sln # Solution file
- Purpose: Test individual components in isolation
- Characteristics:
- No external dependencies (database, network, file system)
- Fast execution
- Deterministic results
- Use mocking for dependencies
- Purpose: Validate end-to-end scenarios
- Characteristics:
- May include external dependencies
- Test component interactions
- Validate complete workflows
- May be slower than unit tests
# Run all tests
dotnet test
# Run only unit tests
dotnet test --filter "FullyQualifiedName~UnitTests"
# Run only integration tests
dotnet test --filter "FullyQualifiedName~IntegrationTests"
# Run tests with coverage
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover# Build the solution
dotnet build
# Build in Release mode
dotnet build -c Release
# Clean build artifacts
dotnet clean# Create a NuGet package
dotnet pack -c Release
# Publish to a folder
dotnet publish -c Release -o ./publishPress Ctrl+Shift+P and type "Tasks" to see available tasks:
- Build: Build the solution
- Test: Run all tests
- Test with Coverage: Run tests with code coverage
- Watch: Watch for file changes and rebuild
This template includes MCP (Model Context Protocol) servers for enhanced AI assistance:
- Context7: Access up-to-date library documentation
- Memory: Maintain context across sessions
- Microsoft Docs: Search official Microsoft documentation
- Sequential Thinking: Problem-solving assistance
- Playwright: Browser automation support
# Install all MCP servers
.\scripts\install-mcps.ps1
# Verify prerequisites only
.\scripts\install-mcps.ps1 -VerifyOnlyThe .github/instructions/ folder contains guidelines for AI assistants:
base.instructions.md: General project guidelinescs.instructions.md: C# coding standards and conventions
This project follows modern .NET best practices:
- ✅ Nullable reference types enabled
- ✅ Implicit usings for common namespaces
- ✅ Latest C# language version
- ✅ XML documentation for public APIs
- ✅ Code analysis with warnings as errors
- ✅ EditorConfig for consistent formatting
- ✅ Source Link for debugging support
See .github/instructions/cs.instructions.md for detailed coding standards.
Update the following in src/YourLibrary/YourLibrary.csproj:
<PropertyGroup>
<PackageId>YourLibrary</PackageId>
<Version>1.0.0</Version>
<Authors>Your Name</Authors>
<Company>Your Company</Company>
<Description>Your library description</Description>
<PackageProjectUrl>https://github.com/yourusername/yourrepository</PackageProjectUrl>
<RepositoryUrl>https://github.com/yourusername/yourrepository</RepositoryUrl>
</PropertyGroup>Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- .NET Documentation
- C# Programming Guide
- xUnit Documentation
- FluentAssertions Documentation
- Model Context Protocol
- Create an issue for bug reports or feature requests
- Check existing issues before creating new ones
- Follow the issue template when available
Happy Coding! 🎉