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

Warning NU5127 msbuild #8941

Closed
MarcoRossignoli opened this issue Dec 15, 2019 · 9 comments
Closed

Warning NU5127 msbuild #8941

MarcoRossignoli opened this issue Dec 15, 2019 · 9 comments
Labels
Functionality:Pack Priority:2 Issues for the current backlog. Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Docs

Comments

@MarcoRossignoli
Copy link

I'm upgrading some project to 3.1 and I get a warning from nuget pack command

C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5127: This package does not contain a lib/ or ref/ folder, and will therefore be treated as compatible for all frameworks. Since framework specific files were found under the build/ directory for netstandard1.0, consider creating the following empty files to correctly narrow the compatibility of the package: [D:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5127: -lib/netstandard1.0/_._ [D:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj]

I'm using msbuild to generage package https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package-msbuild

First question, is there way to generate empty folder using msbuild?

If I create correct structure under project with an empty file called _._ and add <TfmSpecificPackageFile Include="$(ProjectDir)\lib\netstandard1.0\_._" PackagePath="lib\netstandard1.0\" /> the warning goes away, but I'm pretty sure that there is a better way to do it.

BTW after update above I get another warning

C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning 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: [D:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5128: - Add a dependency group for .NETStandard1.0 to the nuspec [D:\git\coverlet\src\coverlet.collector\coverlet.collector.csproj]

and again the question above, is there a way to fix this warning adding a dependecy group using msbuild style?I didn't find anything on guide and I'm not using nuspec.

This is the project file https://github.com/tonerdo/coverlet/blob/master/src/coverlet.collector/coverlet.collector.csproj

@nkolev92
Copy link
Member

Hey @MarcoRossignoli

Are you still waiting on for any of these questions?
Looks to me that you've already managed to unblock yourself.

Thanks.

@nkolev92 nkolev92 added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP Priority:2 Issues for the current backlog. labels May 18, 2020
@MarcoRossignoli
Copy link
Author

MarcoRossignoli commented May 18, 2020

I haven't fixed yet... tomorrow I'll give it another try and if issue is still present I'll come back

@MarcoRossignoli
Copy link
Author

MarcoRossignoli commented May 19, 2020

Confirm the error is still present, to repro clone branch https://github.com/MarcoRossignoli/coverlet/tree/nugetissue
From root project run dotnet pack
Let me know if I'm missing something the project is src\coverlet.collector

@nkolev92
Copy link
Member

I am hitting 5128 right now, is that you were seeing too?

It's seeing lib/, but not dependencies entries whatsoever.

cc @zivkan who's looking into these.

@zivkan
Copy link
Member

zivkan commented May 20, 2020

My analysis of this issue:

  • This package is build tools, so wants only to contain build/ files, and does not list the project's dependencies as package dependencies (by using SuppressDependenciesWhenPacking)
  • NU5127 warns that the package is considered compatible with all TFMs unless there are lib/ or ref/ files, so the package correctly adds lib/<tfm>/_._ file.
  • Now that the project has a lib/<tfm> folder, NU5128 is complaining because there's no dependency group
  • The project compiles with netcoreapp2.0, but puts build files in build/netstandard1.0/, so disabling SuppressDependenciesWhenPacking will create dependencies for the wrong TFM.

So, this is an unusual package, as most packages are not intended to have only build assets. But it's a good scenario, so it's something we should make easier, or at the very least document guidance on how to create such a package without warnings.

What would be helpful is a way to create arbitrary dependency groups, even if there are no dependencies for that group.

Package authors can put arbitrary files in arbitrary locations in the package by using PackagePath, but I don't currently know if it's possible to do something similar for dependencies. Taking a quick look at NuGet.Build.Tasks.Pack.targets, I don't see anything obvious that might help.

In any case, I don't consider this a bug with NU5128, the issue the warning is trying to reduce is impacting this package. But as stated previously, we need a way for package authors of these types of packages to be able to create their package without warnings.

@nkolev92
Copy link
Member

Package authors can put arbitrary files in arbitrary locations in the package by using PackagePath, but I don't currently know if it's possible to do something similar for dependencies. Taking a quick look at NuGet.Build.Tasks.Pack.targets, I don't see anything obvious that might help.

You are correct, there's no way to do that: #8133.

At this point I'd suggest to rename this issue to call NU5128 and maybe mark it as blocked by 8133?

Thoughts @zivkan?

@zivkan zivkan removed the WaitingForCustomer Applied when a NuGet triage person needs more info from the OP label May 20, 2020
@zivkan
Copy link
Member

zivkan commented Jun 9, 2020

I think the root cause for this issue is an exact duplicate of 8133, it's just the learning to get to this understanding, or the customer scenario that leads to the same feature request, isn't detailed in the other issue. I know it wouldn't be ideal to the author of this issue, but depending on how we want to track issues, I'd be fine with either closing this issue as a duplicate, or marking the other one as blocking this one. It's just that once the other issue is fixed, then there's probably nothing to do in this issue, except maybe validate that this scenario is now unblocked.

@nkolev92
Copy link
Member

nkolev92 commented Jun 9, 2020

My preference would be to close it. It provides a better visibility of the backlog and it also gives us an opportunity to upvoet #8133 and increase it's priority as we discover more scenarios.

@zivkan zivkan added the Resolution:Duplicate This issue appears to be a Duplicate of another issue label Jun 13, 2020
@zivkan
Copy link
Member

zivkan commented Jun 13, 2020

Closing as duplicate of #8133

@zivkan zivkan closed this as completed Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Pack Priority:2 Issues for the current backlog. Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Docs
Projects
None yet
Development

No branches or pull requests

5 participants