From 85ede7a8bfd20e86c141c1b56710142190230137 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Mon, 20 Mar 2023 15:22:55 -0300 Subject: [PATCH] Make NuGetizer targets buildTransitive to fix SponsorLink For development-dependency packages, no assets flow across project references, including build targets and package dependencies. This is problematic for SponsorLink since it needs targets to properly surface build properties to the analyzer that performs the checks. By making NuGetizer build targets transitive, we fix the project to project (P2P) scenario where one project installs NuGetizer and referencing projects start failing the SponsorLink check because the SL targets are missing. (since the package dependency on SL isn't surfaced in that case). By also including the SL targets in our package and conditionally importing them if they haven't already been imported, we further remove the changes that the missing dependency causes failures. This might not be the optimal way to solve this, but it's the only one that works consistently. This obviously causes P2P references to a project consuming NuGetizer to *also* become nugetized themselves. This should be a minor issue, however. --- src/CodeAnalysis/CodeAnalysis.csproj | 7 +++++-- src/CodeAnalysis/NuGetizer.CodeAnalysis.targets | 11 +++++++++-- src/NuGetizer.Tasks/NuGetizer.Tasks.targets | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/CodeAnalysis/CodeAnalysis.csproj b/src/CodeAnalysis/CodeAnalysis.csproj index d3585631..f6dd728f 100644 --- a/src/CodeAnalysis/CodeAnalysis.csproj +++ b/src/CodeAnalysis/CodeAnalysis.csproj @@ -14,11 +14,14 @@ - + - + + diff --git a/src/CodeAnalysis/NuGetizer.CodeAnalysis.targets b/src/CodeAnalysis/NuGetizer.CodeAnalysis.targets index 5b4dd341..0d754885 100644 --- a/src/CodeAnalysis/NuGetizer.CodeAnalysis.targets +++ b/src/CodeAnalysis/NuGetizer.CodeAnalysis.targets @@ -18,8 +18,6 @@ - - @@ -29,4 +27,13 @@ + + + + + + diff --git a/src/NuGetizer.Tasks/NuGetizer.Tasks.targets b/src/NuGetizer.Tasks/NuGetizer.Tasks.targets index 33efd8f7..f5661eff 100644 --- a/src/NuGetizer.Tasks/NuGetizer.Tasks.targets +++ b/src/NuGetizer.Tasks/NuGetizer.Tasks.targets @@ -19,7 +19,7 @@ Simple, flexible and powerful NuGet packaging true - build + buildTransitive true ..\..\bin