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

NoWarn=NU1511 doesn't work on a ProjectReference #14121

Open
ViktorHofer opened this issue Feb 21, 2025 · 1 comment
Open

NoWarn=NU1511 doesn't work on a ProjectReference #14121

ViktorHofer opened this issue Feb 21, 2025 · 1 comment
Assignees
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Type:Bug

Comments

@ViktorHofer
Copy link

ViktorHofer commented Feb 21, 2025

There are cases where we want to reference a project that is inbox in a given framework which will emit a NU1511 warning as the direct P2P can't be pruned from the restore graph. This is fine as in such a case, it shouldn't be pruned. It would be great if we could NoWarn this warning just for that single P2P so that we still get others flagged.

Example

a.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\b\b.csproj" NoWarn="NU1511" />
  </ItemGroup>

</Project>

b.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PackageId>System.Collections.Immutable</PackageId>
  </PropertyGroup>

</Project>
C:\temp\prunep2p> C:\git\dotnet-sdk-10.0.100-preview.2.25111.9-win-x64\dotnet.exe restore .\a\a.csproj
Restore succeeded with 1 warning(s) in 0.5s
    C:\temp\prunep2p\a\a.csproj : warning NU1511: A ProjectReference cannot be pruned, System.Collections.Immutable.                                                                                                                                          
Build succeeded with 1 warning(s) in 1.0s

@nkolev92 maybe NoWarn on an item is only supported for PackageReference and not ProjectReference?

Issue is missing Type label, remember to add a Type label

@microsoft-github-policy-service microsoft-github-policy-service bot added the missing-required-type The required type label is missing. label Feb 21, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot removed missing-required-type The required type label is missing. labels Feb 21, 2025
@nkolev92 nkolev92 self-assigned this Feb 21, 2025
@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. Category:Quality Week Issues that should be considered for quality week labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests

2 participants