본문으로 건너뛰기
Skillpedia
배포 및 클라우드 (DevOps)5.8k · #14600

extension-points

하는 일

이 스킬은 MSBuild가 사용자 정의 훅과 NuGet 패키지가 추가하는 빌드 파일 같은 확장 지점을 어떻게 찾는지 설명하고 추적합니다. 사용자 정의 빌드 단계가 빠져 있거나 잘못된 순서로 실행될 때 원인을 찾는 빌드 엔지니어를 위한 스킬입니다.

사용하는 경우

  • ✓사용자 정의 빌드 훅이나 가져오기가 실행되지 않을 때.
  • ✓NuGet 패키지의 빌드 파일이 없거나 교체된 것처럼 보일 때.
  • ✓빌드 사용자 정의가 어디서 로드되는지 알고 싶을 때.

스킬 링크

https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/extension-points/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet-msbuild/skills/extension-points/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 NuGet 패키지의 빌드 대상이 제 프로젝트에서 실행되지 않습니다. MSBuild가 어디서 그것을 로드하고 왜 그런지 추적해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 표준 빌드 파일의 가져오기 순서를 따라가고, 훅 속성과 패키지 구조를 확인하며, 어떤 파일이 로드되거나 건너뛰어지는지 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

MSBuild Extension Points

How the MSBuild pipeline provides hooks for SDKs, NuGet packages, repos, and users to inject custom logic.

CustomBefore / CustomAfter Hooks

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)')"/>

Rules

  • Default path includes version (v$(MSBuildToolsVersion)) for side-by-side installations.
  • Always check Exists(). The file may not be present on every machine.
  • Append to the property (don't overwrite) to chain multiple hooks:
<PropertyGroup>
  <CustomBeforeMicrosoftCommonTargets>
    $(CustomBeforeMicrosoftCommonTargets);$(MSBuildThisFileDirectory)MyExtension.targets
  </CustomBeforeMicrosoftCommonTargets>
</PropertyGroup>

Wildcard Import Directories

MSBuild imports all files in extension directories, sorted alphabetically:

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Imports\Microsoft.Common.props\ImportBefore\*"
    Condition="'$(ImportByWildcardBeforeMicrosoftCommonProps)' == 'true'
               and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Imports\Microsoft.Common.props\ImportBefore')" />

Key paths

Property Resolves to Scope
$(MSBuildUserExtensionsPath) %APPDATA%\Microsoft\MSBuild Per-user
$(MSBuildExtensionsPath) MSBuild install directory Machine-wide
$(MSBuildProjectExtensionsPath) obj/ directory Per-project (NuGet)

Name files with numeric prefixes for ordering: 01-first.props, 02-second.props.

Import Gating — Control Properties

Every wildcard import is gated by a boolean property:

<PropertyGroup>
  <ImportByWildcardBeforeMicrosoftCommonProps
      Condition="'$(ImportByWildcardBeforeMicrosoftCommonProps)' == ''">true</ImportByWildcardBeforeMicrosoftCommonProps>
  <ImportDirectoryBuildProps
      Condition="'$(ImportDirectoryBuildProps)' == ''">true</ImportDirectoryBuildProps>
</PropertyGroup>

Available control properties

Property What it disables
ImportDirectoryBuildProps Directory.Build.props auto-discovery
ImportDirectoryBuildTargets Directory.Build.targets auto-discovery
ImportProjectExtensionProps NuGet-generated *.props in obj/
ImportProjectExtensionTargets NuGet-generated *.targets in obj/
ImportByWildcardBefore* Machine-level ImportBefore extensions
ImportByWildcardAfter* Machine-level ImportAfter extensions

NuGet Package Build Extension Layout

NuGet packages inject build logic via build/ or buildTransitive/ folders:

MyPackage/
  build/
    MyPackage.props      ← imported via *.props wildcard
    MyPackage.targets    ← imported via *.targets wildcard
  buildTransitive/
    MyPackage.props      ← imported by transitive consumers
    MyPackage.targets

Rules

  • File names must match the package ID exactly.
  • build/ affects direct consumers only. buildTransitive/ affects the entire dependency chain.
  • Props are imported early (before the project), targets are imported late (after the project).

Forwarding chain: buildTransitive/ → build/ → shared

Forward buildTransitive/*.props and buildTransitive/*.targets through their sibling build/*.props / build/*.targets files (chain buildTransitive → build → shared) instead of importing buildMultiTargeting/ directly. This keeps build/ as the single source of truth with a clear ownership chain, so transitive consumers stay in sync with direct consumers instead of the two layouts drifting apart.

When build/ is packed per-TFM (build/<tfm>/, via TfmSpecificPackageFile, a per-TFM <PackagePath>, or SDK conventions) while buildMultiTargeting/ is not, a buildTransitive/<tfm>/ forwarder must include the TFM segment — dropping it resolves to a non-existent package-root build/MyPackage.props and fails tra

자주 묻는 질문

CustomBefore 훅이란 무엇인가요?

MSBuild가 주 빌드 대상보다 먼저 가져오는 훅 파일이라서, 사용자 정의 단계를 추가할 수 있습니다.

NuGet 빌드 파일도 다루나요?

네. 패키지 빌드 파일이 가져와지고 일치하는 방식을 다룹니다.

빌드를 바꾸나요?

가져오기를 설명하고 추적합니다. 변경은 검토한 뒤 적용합니다.

상세 정보

작성자의 원본 설명

Own MSBuild import and hook discovery. USE FOR: CustomBefore/CustomAfter hooks, ordered wildcard and NuGet auto-imports, control properties, build/buildTransitive packed layout, package ID and file-name matching, per-TFM forwarders, and tracing why assets or hooks are missing, broken, or replaced. An import guard remains in scope when it is one defect in a broader hook/import flow. DO NOT USE for a focused safety verdict on whether one specific Import needs Exists or is an intentionally unguarded package contract; use msbuild-antipatterns. NEVER INVOKE when imports and hook placement already w

repo: dotnet/skills

인기도

GitHub 스타
5.8k
순위
#14600
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬