Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure private assets always for NuGetizer #355

Merged
merged 1 commit into from
Mar 20, 2023
Merged

Ensure private assets always for NuGetizer #355

merged 1 commit into from
Mar 20, 2023

Conversation

kzu
Copy link
Member

@kzu kzu commented Mar 20, 2023

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.

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.
@kzu kzu added the enhancement New feature or request label Mar 20, 2023
@kzu kzu enabled auto-merge (rebase) March 20, 2023 20:32
@kzu kzu merged commit 84a2483 into main Mar 20, 2023
@kzu kzu deleted the dev/AlwaysPrivate branch March 20, 2023 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant