including-generated-files

Includes build-generated files into MSBuild compilation, output, and clean targets.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/Netcodr81/kinetic-reports --skill including-generated-files-netcodr81
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: including-generated-files
Source: https://github.com/Netcodr81/kinetic-reports/tree/main/.github/skills/including-generated-files
Command: npx skills add https://github.com/Netcodr81/kinetic-reports --skill including-generated-files-netcodr81

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Files generated during an MSBuild build are invisible to the build process because globs expand during the evaluation phase, before those files exist. This causes generated source files to be skipped by the compiler (e.g., CS0246 errors), generated content to be missing from the output directory, and stale artifacts to survive the Clean target. ## Core Features & Use Cases - Correct Target Timing: Guides selection of BeforeTargets values (CoreCompile, BeforeCompile, BeforeBuild, AssignTargetPaths) so generated files are registered at the right moment in the build pipeline. - Item Group Registration: Shows how to add generated files to Compile, None, Content, and FileWrites item groups inside the generating target so they compile, copy to output, and get cleaned. - Path Best Practices: Enforces use of $(IntermediateOutputPath) instead of hardcoded obj/ paths so targets work with redirected intermediate output directories. - Use Case: A custom MSBuild task generates a .cs file during the build, but the compiler reports the type does not exist. This Skill explains adding the file to Compile and FileWrites with BeforeTargets="CoreCompile;BeforeCompile" to fix it. ## Quick Start Ask the AI to fix an MSBuild target whose generated .cs file is not being compiled by adding it to the Compile and FileWrites item groups with the correct BeforeTargets timing.

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 source files in MSBuild compilation?▼

Add the generated file to the Compile item group inside the target that creates it, and hook that target with BeforeTargets="CoreCompile;BeforeCompile". Also add the file to FileWrites so the Clean target removes it.

Why are my MSBuild-generated files not being compiled?▼

Globs outside targets expand during the evaluation phase, before your files exist. Files generated during execution are never seen by those globs, so you must explicitly add them to Compile inside a target that runs before CoreCompile.

What BeforeTargets value should I use for generated files in MSBuild?▼

Use BeforeBuild for non-code files added to None or Content, CoreCompile;BeforeCompile for generated source files added to Compile, and AssignTargetPaths as a fallback when BeforeBuild runs too early for item transforms.

How do I make MSBuild Clean remove generated files?▼

Add every generated file to the FileWrites item group inside the generating target. The Clean target uses FileWrites to know which files to delete, so unregistered files accumulate as stale artifacts.

Should I hardcode the obj folder path for generated files?▼

No. Always use $(IntermediateOutputPath) as the base directory, because the intermediate output path can be redirected in shared output or CI configurations. Hardcoding obj\ breaks the target in those environments.

Does this approach apply to C# source generators or T4 templates?▼

No. C# source generators already integrate through the Roslyn compiler pipeline, and T4 design-time generation runs inside Visual Studio. This guidance targets custom MSBuild targets and tasks that create files during build execution.