NuGet Warning NU5130

Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder have compatible matches, but not exact matches in the other location. Unless intentional, consult the list of actions below:
- Add a dependency group for .NETFramework4.7.2 to the nuspec

Issue

The lib/<tfm>/ or ref/<tfm>/ directory in the package contains at least one file for the Target Framework Moniker (TFM) specified in the warning message. However, no dependency group exists for this TFM in the nuspec file. This may cause package consumers to believe the package is not compatible with the TFM. If the assemblies for the specified TFM have different dependencies to the compatible TFM defined in the dependencies group, the project using the package may experience runtime failures.

Solution

  • Run NuGet's pack target on the project

If possible, use NuGet's MSBuild pack target, as it automatically matches assembly TFMs with dependency groups from the project's target frameworks. Note that your project must use PackageReference for its own NuGet dependencies. If your project uses packages.config, you need to use nuget.exe pack and a nuspec file.

  • Manually edit the nuspec file

If you are using a custom nuspec file, we recommend each TFM for which lib/ or ref/ assemblies exist should have a matching dependency group, even if the dependencies are the same as the next compatible TFM. For example, if a package contains netstandard1.0 and netstandard2.0 assemblies, and the dependencies are the same for both, we recommend both TFMs be listed as dependency groups with duplicate dependency items.

Note that the TFM identifier used in the assembly paths use a different format to the TFM identifier used in dependency groups. The warning message specifies the correct name to use in the dependency group. If your package does not have any dependencies for that target framework, use an empty group. For example:

<package>
  <metadata>
    ...
    <dependencies>
      <group targetFramework=".NETFramework4.7.2" />
    </dependencies>
  </metadata>
  ...
<package>
  • Remove the lib/ or ref/ files

If you do not wish your package to be compatible with the reported TFM, modify your project such that no lib/<tfm>/ or ref/<tfm>/ files are in the package for that TFM. For example, if the warning says to add a dependency group for .NETFramework4.7.2 to the nuspec, then remove any lib/net472/* and ref/net472/* files from your package.