NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 250 forks source link

Missing CPM PackageVersion causes an NRE in PM UI due to restore errors #13627

Open nkolev92 opened 1 month ago

nkolev92 commented 1 month ago

Affected Branch: main Affected Build: Version 17.12.0 Preview 1.0 [35110.85.main] Affected Product Language: English/All

Steps to reproduce:

  1. Construct a package using Central Package Management but miss a PackageVersion for one of the PackageReference items

  2. Open in Visual Studio

  3. Solution Explorer -> Right click on Solution node -> Manage Nuget Packages for Solution...

  4. Displayed yellow bar for "Error Occurred" a84f0746-a42c-4932-9edf-b8b7f3b6fdc8

  5. Click on "Show Errors in Output" RESULT: d589c0b5-b09a-496a-869d-53eda3f23316

EXPECT:

I see errors in several places in this condition, but for all of them, they say "Value cannot be null, Parameter name: versionRange". If they included what package was the issue, then I can track it down. In fact, because the version is empty/null/not displayed, the only piece of information I have to track this down is the packageName. If it had a version and the version was simply not valid SemVer or not found in a source, I could look at the small set of packages with that version to find the cause.

NOTE There is a warning in the Error List: Severity Code Description Project File Line Suppression State Details Error NU1010 The PackageReference items Microsoft.VisualStudio.Editor do not have corresponding PackageVersion. EntityDesigner D:\dd\ef6tools\src\EFTools\EntityDesignEntityDesigner\EntityDesigner.csproj 1

But the link in the UI brings me to the Package Manager Output window, which doesn't have such a clear message.

exaiwitmx commented 1 month ago

I also have this error after converting to Central Package References: image

By conversion, I mean the following:

I've double-checked that all PackageReference elements present in any project file have a corresponding PackageVersion element in Directory.Packages.props.

I also get an error in the error list, but no project name/path mentioned there: image

If I try to restore the Nuget Packages for the solution, I get a few errors like this one: The PackageReference items Microsoft.Graph;Microsoft.Identity.Client do not have corresponding PackageVersion. But the corresponding PackageVersion elements are present in Directory.Packages.props.

Visual Studio Professional 2022 (64bit), Version 17.10.0

exaiwitmx commented 1 month ago

Never mind - I was actually checking/editing the wrong Directory.Packages.props in a different working copy. The relevant one was actually missing some PackageVersion elements.

Time to have a break, I guess.

ardalis commented 1 month ago

Running into this as well trying to use a private GitHub org NuGet feed. I'm trying to "Manage NuGet Packages for Solution in VS 2022: Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.10.5

Output: image

Looking at an individual project works - it's when I try for the whole solution that the error occurs.

SueSu01 commented 1 month ago

This issue also reproes for creating iOS App (Xamarin).

Repro steps:

  1. Create a iOS App (Xamarin)(iPhone Master-Detail App)
  2. Right-click the project in Solution Explorer and select “Manage NuGet Packages…” menu item to open PM UI.
  3. Displayed yellow bar for "Error Occurred" image
voroninp commented 2 weeks ago

Error occurred while restoring NuGet packages: System.NullReferenceException: Object reference not set to an instance of an object. at NuGet.ProjectModel.PackagesLockFileUtilities.<>c.b6_3(LibraryDependency e) at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.OrderedEnumerable1.d1.MoveNext() at System.String.Join(String separator, IEnumerable1 values) at NuGet.ProjectModel.PackagesLockFileUtilities.HasDirectPackageDependencyChanged(IEnumerable1 newDependencies, IEnumerable`1 lockFileDependencies, NuGetFramework nuGetFramework) at NuGet.ProjectModel.PackagesLockFileUtilities.IsLockFileValid(DependencyGraphSpec dgSpec, PackagesLockFile nuGetLockFile) at NuGet.Commands.RestoreCommand.d78.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Commands.RestoreCommand.d71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Commands.RestoreRunner.d7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Commands.RestoreRunner.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Commands.RestoreRunner.d10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NuGet.Commands.RestoreRunner.d2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Commands.RestoreRunner.d0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.PackageManagement.DependencyGraphRestoreUtility.d2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.<>cDisplayClass29_0.<b2>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.RestoreOperationLogger.d35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NuGet.SolutionRestoreManager.RestoreOperationLogger.d35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NuGet.SolutionRestoreManager.SolutionRestoreJob.d27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.SolutionRestoreManager.SolutionRestoreJob.d26.MoveNext() Value cannot be null. Parameter name: versionRange

donnie-msft commented 2 weeks ago

This issue also reproes for creating iOS App (Xamarin).

Repro steps:

  1. Create a iOS App (Xamarin)(iPhone Master-Detail App) ...

@SueSu01 this sounds like a different issue. Could you check this one I filed recently and comment there if you feel it's what you encountered? I see your Restore hasn't completed, so thinking it might be that restore is disabled and not related to CPM.

https://github.com/NuGet/Home/issues/13722

donnie-msft commented 6 hours ago

Developer Community VS Feedback ticket: https://developercommunity.visualstudio.com/t/ResolvePackageAssets-fails-when-using-ce/10740120