Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Adds generated files to Compile and FileWrites item groups so MSBuild compiles, outputs, and cleans build-generated files.
68% 100%+32 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 15 of 22 without it.
Write an MSBuild target named `GenerateCodeAssets` that generates multiple `.cs` files into a subfolder of the intermediate output path and uses a glob pattern inside the target to register them all for compilation and clean.
The Compile item group uses a wildcard glob pattern inside the target
3 of 3 safety checks passed
Files generated during the build are generally ignored by the build process. This leads to confusing results such as:
This happens because of how MSBuild's build phases work.
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"
For detailed explanation, see How MSBuild Builds Projects.
MSBuild reads your project, imports everything, creates Properties, expands globs for Items outside of Targets, and sets up the build process.
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).
Next to this one in the catalogue, plus more from the same author.