Skip to content

Support MSBuild extension files in sample projects when referencing projects under test via ProjectReference#666

Open
delatrie wants to merge 2 commits into
mainfrom
test-msbuild-ext
Open

Support MSBuild extension files in sample projects when referencing projects under test via ProjectReference#666
delatrie wants to merge 2 commits into
mainfrom
test-msbuild-ext

Conversation

@delatrie

@delatrie delatrie commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Context

The PR adds support for automatically importing MSBuild extension files build and buildTransitive in generated sample projects when they reference projects under test directly (i.e., via ProjectReference).

  • Extensions of dependencies are included before extensions of dependents.
  • .props are imported at the beginning of Directory.Build.props
  • .targets are imported at the end of Directory.Build.targets
  • The files are detected by loading the referenced projects with MSBuild and analyzing the _PackageFiles items returned by the _GetPackageFiles target. The files can be stored anywhere and called anything as long as they are correctly mapped to one of the following locations via the PackagePath:
    • /build/<ProjectName>.props
    • /build/<ProjectName>.targets
    • /buildTransitive/<ProjectName>.props
    • /buildTransitive/<ProjectName>.targets
  • Files from /build are only imported for the direct references.

When projects under test are referenced as packages (via PackageReference), no extra support is required as NuGet imports these extensions for us.

This is a prerequisite for implementing integration tests for xunit.v3 and MTP adapters. Without it, we would be required to pack the target projects each time we test them, which would increase the dev loop and require cleaning the NuGet cache.

Checklist

@delatrie delatrie added the type:internal Change that isn't visible or obvious for end users label Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:build type:internal Change that isn't visible or obvious for end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant