DEV Community

Cover image for MSBuild warning NU1510
Karen Payne
Karen Payne

Posted on

MSBuild warning NU1510

Introduction

Learn about PackageReference warnings when a NuGet package is added to a Microsoft project targeting .NET 9, for instance, Microsoft.AspNetCore.Mvc.Core without a warning until upgrading to .NET10, at which time a yellow yield icon appears on the package, in this case, Microsoft.AspNetCore.Mvc.Core under dependencies in the Visual Studio project.

package dependency warning

Actions

First action, from the developer PowerShell window, change to the root of the project and execute the following.

dotnet list package --vulnerable
Enter fullscreen mode Exit fullscreen mode

We get:

warning NU1510: PackageReference Microsoft.AspNetCore.Mvc.Core will not be pruned. This package is automatically available and does not need to be referenced explicitly. Remove the PackageReference item.
Enter fullscreen mode Exit fullscreen mode

A novice solution seeing NU1510 is shown below because they do not see the entire message where the solution is Remove the PackageReference item as it is part of the framework.

novice solution

Our project file now as the NuGet package is not required with .NET10 Core.

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

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

    <ItemGroup>
         <FrameworkReference Include="Microsoft.AspNetCore.App" />
    </ItemGroup>

</Project>
Enter fullscreen mode Exit fullscreen mode

Postmortem

When in Visual Studio, and you see a yield icon, run dotnet list package –vulnerable and read the entire output, whether the warning is NU1510 or another. If the recommendation is unclear, do a web search; in most cases, it will return to the Microsoft page for that warning.

Project file

Resources

Top comments (0)