Contributing to .NET Scaffolding
February 13, 2026 · View on GitHub
Thank you for your interest in contributing to .NET Scaffolding! This document provides guidelines and instructions for contributing to this repository.
Table of Contents
- Code of Conduct
- Getting Started
- Repository Structure
- Development Workflow
- Making Code Changes
- Testing Your Changes
- Submitting Your Changes
- Reporting Issues
Code of Conduct
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Getting Started
Prerequisites
Before you begin, ensure you have the following installed:
-
Preview .NET SDK:
- Download a preview version that matches the version in
global.jsonat the root of the repository - Reference: https://github.com/dotnet/sdk/blob/main/documentation/package-table.md
- Download a preview version that matches the version in
-
Development Environment:
- Visual Studio 2022 (latest preview) OR
- Visual Studio Code with C# Dev Kit extension
-
Git: For cloning the repository and version control
-
Azure CLI (if working on Azure-related features):
az login
Cloning the Repository
git clone https://github.com/dotnet/Scaffolding.git
cd Scaffolding
We recommend cloning under your user profile directory for easier access.
Repository Structure
Understanding the repository structure is crucial for making contributions:
Scaffolding/
├── src/
│ ├── dotnet-scaffolding/
│ │ └── dotnet-scaffold/
│ │ ├── AspNet/ # ASP.NET scaffolders
│ │ │ ├── Templates/ # Templates organized by .NET version
│ │ │ │ ├── net8.0/
│ │ │ │ ├── net9.0/
│ │ │ │ ├── net10.0/ # .NET 10 templates
│ │ │ │ │ ├── BlazorCrud/
│ │ │ │ │ ├── BlazorEntraId/
│ │ │ │ │ ├── BlazorIdentity/
│ │ │ │ │ ├── Identity/
│ │ │ │ │ ├── MinimalApi/
│ │ │ │ │ ├── RazorPages/
│ │ │ │ │ ├── Views/
│ │ │ │ │ └── CodeModificationConfigs/ # JSON configs for code changes
│ │ │ │ └── net11.0/
│ │ │ ├── ScaffoldSteps/ # Step implementations
│ │ │ ├── Commands/ # Command definitions
│ │ │ └── Helpers/ # Helper utilities
│ │ ├── Aspire/ # Aspire scaffolders
│ │ │ └── CodeModificationConfigs/
│ │ │ └── net11.0/ # Aspire code modification configs
│ │ └── ...
│ ├── MSIdentityScaffolding/ # dotnet msidentity tool
│ └── Scaffolding/ # Legacy scaffolding (maintenance mode)
├── test/
│ ├── dotnet-scaffolding/
│ │ └── dotnet-scaffold.Tests/
│ │ └── AspNet/ # Unit tests for ASP.NET scaffolders
│ └── MSIdentityScaffolding/
├── docs/ # Documentation
│ ├── Getting-Started.md
│ └── ...
├── scripts/ # Build and install scripts
│ ├── install-scaffold.cmd
│ └── install-scaffold.sh
└── All.sln # Main solution file
Key Directories
-
Templates: Located in
src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/{version}/- Contains T4 templates (
.ttfiles) for generating code - Organized by .NET version (net8.0, net9.0, net10.0, net11.0)
- Each scaffolder type has its own subfolder
- Contains T4 templates (
-
CodeModificationConfigs: Located in:
src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/{version}/CodeModificationConfigs/src/dotnet-scaffolding/dotnet-scaffold/Aspire/CodeModificationConfigs/{version}/- Contains JSON files that define code modifications
- Examples:
blazorEntraChanges.json,identityChanges.json
-
ScaffoldSteps: Located in
src/dotnet-scaffolding/dotnet-scaffold/AspNet/ScaffoldSteps/- Contains the logic for each scaffolding step
- Implement the
ScaffoldStepbase class
-
Tests: Located in
test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/- Unit tests for scaffolding functionality
- Mirror the structure of the source code
Development Workflow
1. Set Up Your Development Environment
-
Open the solution in your IDE:
# Visual Studio start All.sln # Visual Studio Code code . -
Restore dependencies:
dotnet restore -
Build the solution:
dotnet build
2. Install Local Development Packages
After making changes, install your local build to test:
Windows (cmd):
scripts\install-scaffold.cmd
macOS/Linux or Windows (PowerShell):
scripts/install-scaffold.sh
These scripts will:
- Build the project
- Uninstall any existing scaffolding tools
- Install your local build globally
- Make
dotnet scaffoldavailable with your changes
3. Development Loop
- Make Changes: Edit the code, templates, or configs
- Rebuild: Build the solution
- Reinstall: Run the install script
- Test: Test your changes (see Testing Your Changes)
- Repeat: Iterate as needed
Making Code Changes
Working with Templates
Templates are the source files used to generate code in user projects.
Locating Templates
- Navigate to
src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/ - Choose the .NET version folder you're updating (e.g.,
net10.0/,net11.0/) - Find the scaffolder type subfolder (e.g.,
BlazorEntraId/,Identity/) - Edit the
.tt(T4 template) files
Example: Updating Blazor Entra ID templates for .NET 10:
src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/net10.0/BlazorEntraId/
├── AuthenticationStateProvider.tt
├── LoginDisplay.tt
└── ...
Template Guidelines
- Test your templates: Ensure generated code compiles and runs
- Follow C# conventions: Use proper naming, formatting, and patterns
- Add comments: Include XML documentation for public APIs
- Parameterize properly: Use template parameters for dynamic values
- Keep it simple: Templates should be readable and maintainable
Working with Code Modification Configs
Code modification configs are JSON files that define how to modify existing code files.
Locating Config Files
For ASP.NET scaffolders:
src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/{version}/CodeModificationConfigs/
For Aspire scaffolders:
src/dotnet-scaffolding/dotnet-scaffold/Aspire/CodeModificationConfigs/{version}/
Example Config Files:
blazorEntraChanges.json- Blazor Entra ID code modificationsidentityChanges.json- ASP.NET Identity modificationsminimalApiChanges.json- Minimal API modifications
Config File Structure
{
"Files": [
{
"FilePath": "Program.cs",
"Usings": [
"Microsoft.AspNetCore.Authentication",
"Microsoft.Identity.Web"
],
"CodeChanges": [
{
"Block": "GlobalStatements",
"CodeSnippet": "builder.Services.AddAuthentication(...);"
}
]
}
]
}
Config Guidelines
- Validate JSON: Ensure your JSON is well-formed
- Test modifications: Verify code changes apply correctly
- Be specific: Use precise code blocks and insertion points
- Handle edge cases: Consider different project structures
Adding New Scaffolders
- Create a new subfolder in
AspNet/Templates/{version}/ - Add your T4 templates
- Create a code modification config if needed
- Implement scaffold steps in
AspNet/ScaffoldSteps/ - Register your scaffolder in
AspNetCommandService.cs - Add unit tests in
test/.../AspNet/
Modifying Existing Scaffolders
- Locate the scaffolder in
AspNet/Templates/{version}/ - Edit the appropriate template files or config files
- Update corresponding scaffold steps if needed
- Update existing tests or add new ones
- Test thoroughly
Testing Your Changes
Testing is required for all contributions. Contributors must add unit tests for new functionality.
Manual Testing
Step 1: Create a Test Project
# Create a test Blazor project
dotnet new blazorserver -n TestApp -f net10.0
cd TestApp
Step 2: Run the Scaffolder
# Example: Add Entra ID authentication
dotnet scaffold aspnet entra-id --help
# Or run without options for interactive mode
dotnet scaffold aspnet entra-id
Step 3: Verify the Results
- Check that files were created correctly
- Ensure the project builds:
dotnet build - Run the project and test functionality:
dotnet run
Step 4: Clean Up
cd ..
rm -rf TestApp
Unit Testing
All code changes must include unit tests.
Locating Tests
Tests are organized to mirror the source structure:
test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/
├── Helpers/
├── ScaffoldSteps/
└── ...
Writing Tests
- Create or locate the appropriate test file
- Use xUnit framework (already configured)
- Follow existing test patterns
- Test both success and failure scenarios
Example Test Structure:
using Xunit;
namespace Microsoft.DotNet.Tools.Scaffold.Tests.AspNet
{
public class MyScaffolderTests
{
[Fact]
public void Should_GenerateCorrectCode_When_ValidInput()
{
// Arrange
var input = "test";
// Act
var result = MyScaffolder.Generate(input);
// Assert
Assert.NotNull(result);
Assert.Contains("expected", result);
}
[Fact]
public void Should_ThrowException_When_InvalidInput()
{
// Arrange
var input = "";
// Act & Assert
Assert.Throws<ArgumentException>(() =>
MyScaffolder.Generate(input));
}
}
}
Running Tests
# Run all tests
dotnet test
# Run specific test project
dotnet test test/dotnet-scaffolding/dotnet-scaffold.Tests/
# Run tests with filter
dotnet test --filter "FullyQualifiedName~BlazorEntra"
# Run tests with verbose output
dotnet test -v detailed
Test Guidelines
- Write tests first (TDD approach recommended)
- Test edge cases: Empty inputs, nulls, invalid data
- Use descriptive names:
Should_DoSomething_When_Condition - Keep tests focused: One assertion per test when possible
- Mock dependencies: Use mocking for external dependencies
- Test both paths: Success and failure scenarios
Integration Testing
For larger changes, perform integration testing:
- Create multiple test projects (Blazor Server, Blazor WASM, MVC, etc.)
- Run scaffolders on each project type
- Build and run each project
- Verify functionality end-to-end
Debugging
Using Visual Studio
- Open
All.slnin Visual Studio - Set breakpoints in your code
- Add the following line near the top of the entry point you want to debug:
System.Diagnostics.Debugger.Launch(); - Run the install script to deploy your changes
- Execute
dotnet scaffoldfrom a terminal - The debugger will launch automatically - attach to the process
Using Visual Studio Code
- Open the repository in VS Code
- Install the C# Dev Kit extension
- Create a launch configuration (
.vscode/launch.json) - Set breakpoints
- Use F5 to start debugging
Common Issues
.configfolders: Delete.configfolders in both the scaffolding repo and test projects- Overlapping SDK versions: Ensure only one version of a preview SDK is installed
- Package cache: Clear NuGet cache if experiencing package issues:
dotnet nuget locals all --clear
Submitting Your Changes
Before Submitting
- ✅ Build succeeds:
dotnet buildcompletes without errors - ✅ All tests pass:
dotnet testshows all green - ✅ New tests added: Unit tests cover your changes
- ✅ Manual testing done: Verified with actual scaffolding scenarios
- ✅ Code formatted: Follow C# coding conventions
- ✅ Documentation updated: Update relevant docs if needed
Creating a Pull Request
-
Fork the repository (if you haven't already)
-
Create a feature branch:
git checkout -b feature/my-awesome-feature -
Make your changes and commit:
git add . git commit -m "Add awesome feature for Blazor scaffolding" -
Push to your fork:
git push origin feature/my-awesome-feature -
Open a Pull Request on GitHub:
- Provide a clear title and description
- Reference any related issues
- Describe what you changed and why
- Include testing steps
Pull Request Guidelines
- Clear description: Explain what changes you made and why
- Link issues: Reference related GitHub issues
- Small PRs: Keep changes focused and manageable
- Test coverage: Include test results or screenshots
- Documentation: Update docs if you changed behavior
- Follow feedback: Be responsive to code review comments
Code Review Process
- A maintainer will review your PR
- Address any feedback or requested changes
- Once approved, your changes will be merged
- Your contribution will be included in the next release!
Reporting Issues
Security Issues
Do not report security issues publicly.
Report security issues and bugs privately to:
- Email: secure@microsoft.com
- Response time: Within 24 hours
- More info: Security TechCenter
Bug Reports
When reporting bugs, please include:
- Description: Clear description of the bug
- Steps to reproduce:
1. Run dotnet new blazorserver 2. Run dotnet scaffold aspnet entra-id 3. See error... - Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Environment:
- OS: Windows 11, macOS 14, etc.
- .NET SDK version:
dotnet --version - Scaffolding version
- Logs/Error messages: Full error output
- Project type: Blazor Server, MVC, Web API, etc.
Feature Requests
For feature requests:
- Check if it already exists in issues
- Provide a clear use case
- Describe the expected behavior
- Consider implementation approach
- Be open to discussion and alternatives
Additional Resources
Documentation
- Getting Started: docs/Getting-Started.md
- Entra ID Scaffolder: docs/ENTRA_ID_SCAFFOLDER_DOCUMENTATION.md
- Main README: README.md
Related Projects
Getting Help
- GitHub Issues: For bugs and feature requests
- GitHub Discussions: For questions and community support
- Stack Overflow: Tag your questions with
dotnet-scaffolding
Quick Reference
Common Commands
# Build the solution
dotnet build
# Run tests
dotnet test
# Install local changes
scripts/install-scaffold.cmd # Windows
scripts/install-scaffold.sh # macOS/Linux
# Test your changes
cd ~/TestProject
dotnet scaffold aspnet --help
Directory Quick Reference
| Component | Location |
|---|---|
| ASP.NET Templates | src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/{version}/ |
| Code Modification Configs (ASP.NET) | src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/{version}/CodeModificationConfigs/ |
| Code Modification Configs (Aspire) | src/dotnet-scaffolding/dotnet-scaffold/Aspire/CodeModificationConfigs/{version}/ |
| Scaffold Steps | src/dotnet-scaffolding/dotnet-scaffold/AspNet/ScaffoldSteps/ |
| Unit Tests | test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/ |
| Documentation | docs/ |
Thank You!
Thank you for contributing to .NET Scaffolding! Your contributions help make .NET development better for everyone.
If you have questions or need help, don't hesitate to:
- Open a GitHub issue
- Start a discussion
- Reach out to the maintainers
Happy coding! 🚀