Skip to content

IncludePackageReferencesDuringMarkupCompilation causes excluded NuGet targets/props files to be executed #4311

Open

Description

@nick-beer

If you conditionally exclude a NuGet package based on whether we're in the wpf MarkupCompile phase (the _wpftmp project), any .targets or .props files in that NuGet packages build folder will still be executed during the _wpftmp build if IncludePackageReferencesDuringMarkupCompilation is true.

This behavior was surprising to me. Now that I've read through the code in Microsoft.WinFX.targets, I can understand the why things happen the way they do, but thought it was worth reporting anyways.

For some background, we use a code analysis NuGet package that I wanted to turn off during the MarkupCompile/inner build of the _wpftmp project. The analyzers are slow, we have more warnings than I'm proud of, and with them enabled during the _wpftmp build we get twice the number of warnings. I thought I would be able to put a condition on the PackageReference that excludes the package if we're in the _wpftmp build. However, when I did that, projects that had IncludePackageReferencesDuringMarkupCompilation set to true failed to build because the package wasn't included but the package's .targets file from the build folder was still executing.

I've created a small project that reproduces the issue. You can get it here.

SDK Version 5.0.104

Metadata

Metadata

Assignees

Labels

Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions