including-generated-files

Add build-generated files to MSBuild item groups with correct timing.

1|Updated May 21, 2026
One-click install
npx skills add https://github.com/1k-off/umbraco-observability-playground --skill including-generated-files-1k-off
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: including-generated-files
Source: https://github.com/1k-off/umbraco-observability-playground/tree/main/.agents/skills/including-generated-files
Command: npx skills add https://github.com/1k-off/umbraco-observability-playground --skill including-generated-files-1k-off

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It fixes MSBuild projects where files created during the build are not seen by later compilation or output steps, causing missing types, incomplete outputs, and confusing glob behavior.

Core Features & Use Cases

  • Include build-generated sources: Add generated .cs files into Compile at the correct time so they are compiled.
  • Include generated non-code artifacts: Add generated files into None/Content for copying and into FileWrites so Clean removes them.
  • Correct ordering and paths: Use BeforeTargets="CoreCompile;BeforeCompile" and $(IntermediateOutputPath) to avoid evaluation-time glob misses and incorrect directories.

Quick Start

Ask the assistant to generate an MSBuild target that adds your build-generated .cs and non-code files to the correct item groups at the right BeforeTargets timing using $(IntermediateOutputPath), including proper FileWrites entries for cleanup.

Frequently Asked Questions about including-generated-files

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

FAQPage Schema
Why does MSBuild ignore my generated files during compilation?

MSBuild ignores generated files because evaluation-time globs execute before custom build tasks run. Adding generated paths to Compile and FileWrites inside a target with BeforeTargets timing using $(IntermediateOutputPath) fixes compilation gaps.

How do I include generated .cs files in MSBuild compilation?

To include generated .cs files in MSBuild compilation, add them to the Compile item group inside a target with BeforeTargets="CoreCompile;BeforeCompile" timing so later targets see the files after generation.

How do I ensure MSBuild Clean removes build-generated files?

To ensure MSBuild Clean removes build-generated files, add generated paths into the FileWrites item group inside your target. This registers them with cleanup so intermediate output files are deleted during Clean.

Can I use BeforeTargets to fix missing generated types in .NET builds?

Yes, you can use BeforeTargets to fix missing generated types in .NET builds. Setting BeforeTargets="CoreCompile;BeforeCompile" ensures generated source files are added to Compile before the compiler executes.

What is the correct path for generated files in MSBuild targets?

The correct path for generated files in MSBuild custom targets is $(IntermediateOutputPath). Using this variable avoids incorrect directories and ensures later compilation targets locate the generated source and content files reliably.

Do I need to add generated non-code files to None or Content in MSBuild?

Yes, generated non-code artifacts must be added to None or Content in MSBuild for copying to output directories. They should also be added to FileWrites so the Clean target removes them properly.