From af4a065e90114127fb2d59bd21b278c7fb952dce Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Mon, 20 Mar 2023 17:32:10 -0300 Subject: [PATCH] Ensure private assets always for NuGetizer Since analyzers are transitive by default (unless PrivateAssets=all in the PackageReference), we could have been inadvertently running SL checks via project-to-project (P2P) references and causing build errors since SL requires some compiler-visible properties surfaced via MSBuild that would otherwise not be available. This can happen if you add a package reference manually and forget to set PrivateAssets=all. But NuGetizer is *always* intended to be private assets. After some testing, it turns out that even if we set the PrivateAssets=all via targets provided by the package itself, we can prevent this abnormal (but perhaps easy to encounter?) situation from happening at all. This is particularly necessary with the introduction of the SponsorLink checks, since those are analyzers too, and require compiler-visible properties to be surfaced. By forcing PrivateAssets, we make sure SponsorLink analyzer never runs on P2P projects and only on the directly referencing one. --- src/NuGetizer.Tasks/NuGetizer.Inference.targets | 2 +- src/NuGetizer.Tasks/NuGetizer.Shared.targets | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/NuGetizer.Tasks/NuGetizer.Inference.targets b/src/NuGetizer.Tasks/NuGetizer.Inference.targets index a7dd6d8a..c9cc0b2a 100644 --- a/src/NuGetizer.Tasks/NuGetizer.Inference.targets +++ b/src/NuGetizer.Tasks/NuGetizer.Inference.targets @@ -195,7 +195,7 @@ Copyright (c) .NET Foundation. All rights reserved. - + + + + + + true