I have a DLL addressing the .NET 4.7.1 library.
Probably irrelevant, but it's written in C# and consumes NuGet packages using the "packages.config" pattern, rather than the newer PackageReference configuration.
I publish this as a NuGet package (have been doing this for several years). But now when I execute the following:
nuget pack -Properties Configuration=Release
I get the following warning:
Error NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below: - Add a dependency group for .NETFramework4.7.1 to the nuspec
I don't have anything in the dependencies group of the nuspec:
<?xml version="1.0"?>
<package >
<metadata>
<id>*******</id>
<version>*******</version>
<title>*******</title>
<authors>*******</authors>
<owners>*******</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>*******</description>
<releaseNotes>*******</releaseNotes>
<copyright>*******</copyright>
<tags>*******</tags>
</metadata>
</package>
This consumes the following NuGet packages:
When I look under the References, I see the following (used ~ to shorten the path):
So to my mind, everything looks like it's .NET 4.7.1 compatible, so why this warning?
Following the details given in NuGet Warning NU5128, I therefore added a dependency group:
<?xml version="1.0"?>
<package >
<metadata>
<id>*******</id>
<version>*******</version>
<title>*******</title>
<authors>*******</authors>
<owners>*******</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>*******</description>
<releaseNotes>*******</releaseNotes>
<copyright>*******</copyright>
<tags>*******</tags>
<dependencies>
<group targetFramework=".NETFramework4.7.1" />
</dependencies>
</metadata>
</package>
But this has no effect, I still get the error.
As per NU5128 doc, This warning was added during NuGet 5.3's development, and first was available in .NET Core SDK 3.0 Preview 9. NuGet/Home#8583 tracks an issue where the warning was being raised in too many scenarios. You can use the NoWarn MSBuild property ( add $ (NoWarn);NU5128 to any PropertyGroup in your project file ).
That command fails if the .nuspec contains any placeholders. Because a NuGet package is just a ZIP file that's been renamed with the .nupkg extension, it's often easiest to create the folder structure you want on your local file system, then create the .nuspec file directly from that structure.
The main component of a Nuget package is the .nuspec file. This is an XML file that represents your package, and contains all the information that Nuget.org requires to publish your package. Whilst not essential, it makes life somewhat easier if you include the .nuspec file in the root of your project.
If the package has undeclared dependencies, the project using the package will experience runtime errors. If possible, use NuGet's MSBuild pack target, as it automatically matches assembly TFMs with dependency groups from the project's target frameworks.
As per NU5128 doc, This warning was added during NuGet 5.3's development, and first was available in .NET Core SDK 3.0 Preview 9. NuGet/Home#8583 tracks an issue where the warning was being raised in too many scenarios. You can use the NoWarn MSBuild property (add $(NoWarn);NU5128 to any PropertyGroup in your project file). If you have multiple projects affected, you can use Directory.Build.targets to automatically add NoWarn to all projects
As of Nuget 5.7 this is now reported as an error from Nuget CLI (https://github.com/NuGet/Home/issues/7404) - So our pipeline started to fail even though we had this error before.
We ended up with the Nowarn approach in relevant csproj files as described above - But I wanted to add that this may suddenly cause issues in already running pipelines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With