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…
Install / Use
npx skills add dotnet/skills --skill including-generated-filesInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of including-generated-files
including-generated-files scores 87/100 on our quality scale, 866th of 2,398 Development & Engineering skills we index (top 37%).
Its SKILL.md is 7.1 KB long, well organised into 14 sections with 4 code examples: a thorough specification that gives an agent plenty to work with.
With 5,471 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 2 days ago, so including-generated-files is actively maintained.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
including-generated-files compared with similar skills
All 4 of these similar skills score higher than including-generated-files; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| including-generated-files (this skill)by dotnet | 87 | 5.5k | 2d ago | SKILL.md |
| ai-job-searchby MadsLorentzen | 100 | 44.0k | 5d ago | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.7k | today | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 4d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 4d ago | SKILL.md |
Frequently asked questions
- How do I install including-generated-files?
- Run
npx skills add dotnet/skills --skill including-generated-files. The install tabs above show the steps for each supported agent. - Which AI agents does including-generated-files work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is including-generated-files safe to use?
- It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is including-generated-files still maintained?
- The repository was last updated 2 days ago, so including-generated-files is actively maintained.
Skill content
View source on GitHubname: including-generated-files description: "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 $(IntermediateOutputPath) instead of hardcoded obj/ paths. DO NOT USE FOR: C# source generators that already work via the Roslyn pipeline, T4 design-time generation that runs in Visual Studio, non-MSBuild build systems." license: MIT
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):
<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.
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 & Tasks with the provided Properties & Items to perform the build.
Key Takeaway: Files generated during execution don't exist during evaluation, therefore they aren't found. This particularly affects files that are globbed by default, such as source files (.cs).
Solution: Manually Add Generated Files
When files are generated during the build, manually add them into the build process. The approach depends on the type of file being generated.
Use $(IntermediateOutputPath) for Generated File Location
Always use $(IntermediateOutputPath) as the base directory for generated files. Do not hardcode obj\ or construct the intermediary path manually (e.g., obj\$(Configuration)\$(TargetFramework)\). The intermediate output path can be redirected to a different location in some build configurations (e.g., shared output directories, CI environments). Using $(IntermediateOutputPath) ensures your target works correctly regardless of the actual path.
Always Add Generated Files to FileWrites
Every generated file should be added to the FileWrites item group. This ensures that MSBuild's Clean target properly removes your generated files. Without this, generated files will accumulate as stale artifacts across builds.
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)my-generated-file.xyz" />
</ItemGroup>
Basic Pattern (Non-Code Files)
For generated files that need to be copied to output (config files, data files, etc.), add them to Content or None items before BeforeBuild:
<Target Name="IncludeGeneratedFiles" BeforeTargets="BeforeBuild">
<!-- Your logic that generates files goes here -->
<ItemGroup>
<None Include="$(IntermediateOutputPath)my-generated-file.xyz" CopyToOutputDirectory="PreserveNewest"/>
<!-- Capture all files of a certain type with a glob -->
<None Include="$(IntermediateOutputPath)generated\*.xyz" CopyToOutputDirectory="PreserveNewest"/>
<!-- Register generated files for proper cleanup -->
<FileWrites Include="$(IntermediateOutputPath)my-generated-file.xyz" />
<FileWrites Include="$(IntermediateOutputPath)generated\*.xyz" />
</ItemGroup>
</Target>
For Generated Source Files (Code That Needs Compilation)
If you're generating .cs files that need to be compiled, use BeforeTargets="CoreCompile;BeforeCompile". This is the correct timing for adding Compile items — it runs late enough that the file generation has occurred, but before the compiler runs. Using BeforeBuild is too early for some scenarios and may not work reliably with all SDK features.
<Target Name="IncludeGeneratedSourceFiles" BeforeTargets="CoreCompile;BeforeCompile">
<PropertyGroup>
<GeneratedCodeDir>$(IntermediateOutputPath)Generated\</GeneratedCodeDir>
<GeneratedFilePath>$(GeneratedCodeDir)MyGeneratedFile.cs</GeneratedFilePath>
</PropertyGroup>
<MakeDir Directories="$(GeneratedCodeDir)" />
<!-- Your logic that generates the .cs file goes here -->
<ItemGroup>
<Compile Include="$(GeneratedFilePath)" />
<FileWrites Include="$(GeneratedFilePath)" />
</ItemGroup>
</Target>
Note: Specifying both CoreCompile and BeforeCompile ensures the target runs before whichever target comes first, providing robust ordering regardless of customizations in the build.
Target Timing
Choose the BeforeTargets value based on the type of file being generated:
BeforeTargets="BeforeBuild"— For non-code files added toNoneorContent. Runs early enough for copy-to-output scenarios.BeforeTargets="CoreCompile;BeforeCompile"— For generated source files added toCompile. Ensures the file is included before the compiler runs.BeforeTargets="AssignTargetPaths"— The "final stop" beforeNoneandContentitems (among others) are transformed into new items. Use as a fallback ifBeforeBuildis too early.
Globbing Behavior
Globs behave according to when the glob took place:
| Glob Location | Files Captured | |---------------|----------------| | Outside of a target | Only files visible during Evaluation phase (before build starts) | | Inside of a target | Files visible when the target runs (can capture generated files if timed correctly) |
This is why the solution places the <ItemGroup> inside a <Target> - the glob runs during execution when the generated files exist.
Relevant Links
Related Skills
ai-job-search
44.0kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.7kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
