-
Notifications
You must be signed in to change notification settings - Fork 256
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
dotnet list package
does not work if project is using central package management system, after upgrading to .NET 8.0
#13632
Comments
Hello! There is a current issue with CPM, NuGet/NuGet.Client#5866, which we're working on fixing. In your setup are you enabling CPM on individual projects or within the Directory.Package.props file? |
Hello @jgonz120! In my setup, the CPM is enabled for the entire solution in a central |
I haven't been able to reproduce this using https://github.com/nkolev92/CentralPackageManagementDemo as an example repo. After cloning I added a global.json file so I could specify the dotnet version and updated the projects to use net7.0 so I could test it in both versions. Are there any differences with that example project and yours that you think could help us get a repro? |
Hello again! I managed to find the culprit but don't know if this is an expected behavior or a bug. Indeed with the project you mentioned I wasn't able to reproduce the issue, so I compared with my local repository. I found out that the only difference in terms of structure and files, was the existence of In this file, there were also global package references mentioned. So I copied the same file in the the example repo and was able to reproduce this using .NET 8.0 SDK. When I moved these references to the Interestingly enough, when I switched .NET SDK to version 7.0 using This begs the question: was this behavior with v7.0 a pre-existing bug that got fixed with v8.0, or is the current behavior a bug? It looks like .NET 7.0 is parsing both Can (or should) To re-create this, I followed these steps:
from |
I can repro it: https://github.com/nkolev92/CentralPackageManagementDemo/tree/listPackageBug. |
Here is what I was able to find out: The asset file generated during restore contains However, as described in the docs, we expect We could address this in two ways
|
I'm not sure if the docs mean to imply that only Directory.Packages.props is supported. There's implied support for PackageVersion and Directory.packages.props for what our tooling can do (dotnet add package and VS updates), but in the end, it's MSBuild, so I'm not sure if that's supposed we're explicitly disallowing. Restore will use items as long as they're defined with the msbuild evaluated project and does not really focus on where that's coming from. Idea #1 would conflict with the MSBuild integration, so probably not a possible solution. I think this is a list package limitation, not something that should drive restore behavior. Why does list package raise an error suggesting that the project assets file is not available? What's the first bug there? |
I agree, 1 would conflict with the MSBuild integeration. For 2, when I said version resolution, I was refering to https://github.com/NuGet/NuGet.Client/blob/15991039d603b8da5d2603315fc9c5c2cfb91a07/src/NuGet.Core/NuGet.CommandLine.XPlat/Utility/MSBuildAPIUtility.cs#L800 where we try to retrieve the version for installed |
Ah, makes sense. Yeah, I think list package needs to just consider the full project for GlobalPackageReference, similarly to how PackageReference is done. |
NuGet Product Used
dotnet.exe
Product Version
8.0.x
Worked before?
7.0.x
Impact
I'm unable to use this version
Repro Steps & Context
dotnet restore
dotnet build
dotnet list package --vulnerable
using any.NET 8.0
SDK (in the example,8.0.303
was used).Expected behavior: The command must complete and list any vulnerable package.
Actual behavior: The command fails as it cannot read the package references.
Since upgrading to
.NET 8.0
, the NuGet command to list packages (with any combination, but particularly with--vulnerable
), is failing to complete when ran against a project which is usingDirectory.Package.props
for managing its dependencies centrally.The command mentions that it is unable to read the package references from the project, like the picture below:
Quite literally the same project and command, when ran using the
.NET 7.0
SDK, is completing without any issues:This does not have to do with the .NET the project targets, as in both examples above the project has been built for
.NET 7.0
, but the command to view the vulnerable packages has been ran using a different SDK vesion (7.0.316
and8.0.303
).Also, it seems that the issue is not re-creatable when the central package management is disabled and versions are mentioned in the
.csproj
files.Verbose Logs
The text was updated successfully, but these errors were encountered: