dotnet-msbuild-execution

Guides writing and ordering MSBuild targets covering hooks, incremental builds, batching, and copy-to-output.

Updated Jun 30, 2026
One-click install
npx skills add https://github.com/bsamiee/Rasm --skill dotnet-msbuild-execution-bsamiee
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-msbuild-execution
Source: https://github.com/bsamiee/Rasm/tree/main/.claude/skills/dotnet-msbuild-execution
Command: npx skills add https://github.com/bsamiee/Rasm --skill dotnet-msbuild-execution-bsamiee

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing custom MSBuild targets in .NET projects often fails due to unclear target ordering, missing incremental Inputs/Outputs, wrong SDK hook points, and copy-to-output rules that silently skip files. This Skill provides the execution-phase knowledge needed to author targets that run at the right time, stay incremental, and produce correct build and publish output. ## Core Features & Use Cases - Target Ordering and SDK Hooks: Explains DependsOnTargets, BeforeTargets, AfterTargets, Returns semantics, and every SDK hook point from Restore through Build, Publish, and Pack. - Incremental and Generated Files: Covers Inputs/Outputs timestamp checks, marker files, FileWrites, and generating source or manifest files under IntermediateOutputPath. - Tasks, Batching, and Errors: Details Exec, Copy, MSBuild, and inline RoslynCodeTaskFactory tasks, metadata batching rules, ContinueOnError modes, and warning-as-error switches. - Use Case: When adding a target that generates a BuildInfo.g.cs file before compilation, use this Skill to hook CoreCompile correctly, declare Inputs and Outputs for incremental builds, and register the file in FileWrites so Clean removes it. ## Quick Start Ask the AI to write an MSBuild target that generates a source file before CoreCompile with proper incremental Inputs and Outputs using this Skill.

Frequently Asked Questions about dotnet-msbuild-execution

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

FAQPage Schema
How do I run an MSBuild target before or after Build in a .NET project?▼

Attach a custom target with BeforeTargets or AfterTargets naming an SDK target such as Build or CoreCompile, or append to a DependsOn property like CompileDependsOn in Directory.Build.targets. Defining a target named AfterBuild in a project file silently loses to the SDK's empty target.

How to make an MSBuild target incremental with Inputs and Outputs?▼

Declare Inputs and Outputs on the target so MSBuild skips it when every output is at least as new as its inputs. Targets without Outputs run every build, and register-only targets should Touch a marker file and add it to FileWrites.

Why is my custom AfterBuild target not running in MSBuild?▼

The implicit Sdk.targets import defines empty BeforeBuild and AfterBuild targets after the project body, so a same-named target in the project file loses silently. Use a uniquely named target with AfterTargets="Build" instead.

Does CopyToOutputDirectory work on files generated by a custom target?▼

Globs outside a target expand during evaluation and cannot see files written later, so the generating target must add the file to an item type like None with CopyToOutputDirectory metadata. Hook before AssignTargetPaths, the last target that assigns TargetPath.

What is the difference between DependsOnTargets and CallTarget in MSBuild?▼

DependsOnTargets runs the named target in the caller's scope so properties and items it sets remain visible. CallTarget runs in a new scope and only TargetOutputs come back, while properties and items it sets stay invisible to the caller.

Why does my MSBuild target run in every inner build of a multi-targeting project?▼

A target attached to Build runs in the outer build and in every inner build dispatched per TargetFrameworks entry. Gate per-assembly work with '$(TargetFramework)' != '' or outer-build work with '$(IsCrossTargetingBuild)' == 'true'.