Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Documents MSBuild extension points: CustomBefore/CustomAfter hooks, wildcard imports, import gating, NuGet build layout, and import guards.
91% 100%+9 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 20 of 22 without it.
I am packaging a multi-targeted NuGet tool called DataSync.Engine with props and targets in both build/ and buildTransitive/ folders per TFM. How should I structure the import logic inside buildTransitive/<tfm>/DataSync.Engine.props so it safely delegates to the corresponding file in build/ across transitive projects without breaking during restore or target evaluation? Please provide the exact MSBuild XML snippet for the transitive props file and explain the path resolution pattern.
The response uses GetFileName and GetDirectoryName on MSBuildThisFileDirectory to derive the TFM folder name rather than using TargetFramework.
3 of 3 safety checks passed
How the MSBuild pipeline provides hooks for SDKs, NuGet packages, repos, and users to inject custom logic.
Every major .targets file defines import hooks:
<PropertyGroup>
<CustomBeforeMicrosoftCommonTargets Condition="'$(CustomBeforeMicrosoftCommonTargets)' == ''">
$(MSBuildExtensionsPath)\v$(MSBuildToolsVersion)\Custom.Before.Microsoft.Common.targets
</CustomBeforeMicrosoftCommonTargets>
</PropertyGroup>
<Import Project="$(CustomBeforeMicrosoftCommonTargets)"
Condition="'$(CustomBeforeMicrosoftCommonTargets)' != '' and Exists('$(CustomBeforeMicrosoftCommonTargets)')"/>
<!-- ... core targets ... -->
<Import Project="$(CustomAfterMicrosoftCommonTargets)"
Condition="'$(CustomAfterMicrosoftCommonTargets)' != '' and Exists('$(CustomAfterMicrosoftCommonTargets)')"/>
v$(MSBuildToolsVersion)) for side-by-side installations.Exists(). The file may not be present on every machine.<PropertyGroup>
<CustomBeforeMicrosoftCommonTargets>
$(CustomBeforeMicrosoftCommonTargets);$(MSBuildThisFileDirectory)MyExtension.targets
</CustomBeforeMicrosoftCommonTargets>
</PropertyGroup>
MSBuild imports all files in extension directories, sorted alphabetically:
Next to this one in the catalogue, plus more from the same author.