including-generated-files
Fix MSBuild targets that generate files during the build but those files are missing from compilation or output. USE FOR: generated source files not compiling (CS0246 for a type that should exist), custom build tasks that create files but they are invisible to subsequent targets, globs not capturing build-generated files because they expand at evaluation time before execution creates them, ensuring generated files are cleaned by the Clean target. Covers correct BeforeTargets timing (CoreCompile, BeforeBuild, AssignTargetPaths), adding to Compile/FileWrites item groups, using $(IntermediateOutp
npx skills add dotnet/skills --skill including-generated-files --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Including Generated Files Into Your Build ## Overview Files generated during the build are generally ignored by the build process. This leads to confusing results such as: - Generated files not being included in the output directory - Generated source files not being compiled - Globs not capturing files created during the build This happens because of how MSBuild's build phases work. ## Quick Takeaway For code files generated during the build - we need to add those to `Compile` and `FileWrites` item groups within the target generating the file(s): ```xml <ItemGroup> <Compile Include="$(GeneratedFilePath)" /> <FileWrites Include="$(GeneratedFilePath)" /> </ItemGroup> ``` The target generating the file(s) should be hooked before CoreCompile and BeforeCompile targets - `BeforeTargets="CoreCompile;BeforeCompile"` ## Why Generated Files Are Ignored For detailed explanation, see [How MSBuild Builds Projects](https://docs.microsoft.com/visualstudio/msbuild/build-process-overview). ### Evaluation Phase MSBuild reads your project, imports everything, creates Properties, expands globs for Items **outside of Targets**, and sets up the build process. ### Execution Phase MSBuild runs Targets
- Overview
- Quick Takeaway
- Why Generated Files Are Ignored
- Evaluation Phase
- Execution Phase
- Solution: Manually Add Generated Files
- Use $(IntermediateOutputPath) for Generated File Location
- Always Add Generated Files to FileWrites
- Basic Pattern (Non-Code Files)
- For Generated Source Files (Code That Needs Compilation)
- Target Timing
- Globbing Behavior
- Relevant Links
What does the including-generated-files skill do?
Fix MSBuild targets that generate files during the build but those files are missing from compilation or output. USE FOR: generated source files not compiling (CS0246 for a type that should exist), custom build tasks that create files but they are invisible to subsequent targets, globs not capturing build-generated files because they expand at evaluation time before execution creates them, ensuring generated files are cleaned by the Clean target. Covers correct BeforeTargets timing (CoreCompile, BeforeBuild, AssignTargetPaths), adding to Compile/FileWrites item groups, using $(IntermediateOutp
How do I install it?
Run `npx skills add dotnet/skills --skill including-generated-files --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From dotnet/skills, a repository with 4,927 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.