including-generated-files

Include generated C# files in MSBuild Compile and FileWrites item groups.

5.1k|377|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/dotnet/skills --skill including-generated-files
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: including-generated-files
Source: https://github.com/dotnet/skills/tree/main/plugins/dotnet-msbuild/skills/including-generated-files
Command: npx skills add https://github.com/dotnet/skills --skill including-generated-files

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the common issue where files generated during the MSBuild build process are not correctly included in compilation, output, or tracked by build system globs, leading to incomplete or incorrect builds.

Core Features & Use Cases

  • Correctly Include Generated Code: Ensures source files generated during the build are compiled.
  • Track Generated Files: Makes sure generated files are included in output directories and properly cleaned up.
  • Use Case: When a custom tool generates C# code during the build, this skill ensures that generated code is compiled and available in the final output.

Quick Start

Use the including-generated-files skill to ensure that any C# files generated in the intermediate output path are compiled.

Frequently Asked Questions about including-generated-files

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I include generated files in MSBuild compilation?

To include generated files in MSBuild compilation, explicitly add them to the Compile and FileWrites item groups within the appropriate build targets so the build system tracks and compiles them correctly.

Why does dotnet build miss my generated source files?

dotnet build misses generated source files because default glob patterns do not automatically track files created in intermediate output paths during the build process, requiring explicit inclusion in the Compile item group.

How to clean up generated files during incremental builds?

To clean up generated files during incremental builds, add the generated files to the FileWrites item group so MSBuild can track them for proper deletion and ensure correct output during subsequent builds.

When do I need to explicitly track generated files in MSBuild?

You need to explicitly track generated files in MSBuild when a custom tool generates C# code during the build process, ensuring the generated code is compiled and available in the final output.

What is the best way to ensure generated code is compiled in dotnet build?

The best way to ensure generated code is compiled during dotnet build is to explicitly include the generated source files in the Compile and FileWrites item groups within your custom MSBuild targets.