_This issue has been moved from a ticket on Developer Community._
[severity:I'm unable to use this version] [regression] [worked-in:16.8.2]
Managing Nuget packages > Browse brings up the following error
! [image.png] (https://aka.ms/dc/image?name=Bca4ae68667b4419392c520bf946e165d637416996804221774_20201123-144121-image.png&tid=ca4ae68667b4419392c520bf946e165d637416996804221774)
Have restarted computer/VS
VS: 16.8.2
! [image.png] (https://aka.ms/dc/image?name=B7bd6f85befdd40a6aa964320715f6281637416997462030978_20201123-144227-image.png&tid=7bd6f85befdd40a6aa964320715f6281637416997462030978)
I did update from VS16.8.1 the other day, not sure if it was part of the upgrade or not
Any help would be appreciated
Thanks
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
(no solutions)
I don't know if this is a 100% repro regression, given that there are no NuGet changes among 16.8.1 and 16.8.2, but the error message is clear.
The issue is happening because of the codespaces changes.
cc @rrelyea @dtivel
cc @aortiz-msft This is a P1 on dev community...worth prioritizing an investigation I think.
https://developercommunity2.visualstudio.com/t/Internal-Error-with-NuGet-Package-Manage/1271505 is another issue with the same root cause.
The NuGet version is 5.8.0.6930 (https://github.com/NuGet/NuGet.Client/commit/830c8be45dbbccd411ecf6080abff0c2c98079cf).
Here is the callstack:
StreamJsonRpc.RemoteInvocationException: An internal error occurred. Please contact Microsoft Support.
at Microsoft.ServiceHub.Framework.ServiceJsonRpcDescriptor.LocalProxyGeneration.<ReturnedValueTaskOfTHelper>d__25`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.VisualStudio.Internal.Contracts.ProjectContextInfo.<GetInstalledPackagesAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.VisualStudio.PackageCollection.<FromProjectsAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.UI.PackageItemLoader.<UpdateStateAndReportAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.UI.InfiniteScrollList.<LoadNextPageAsync>d__55.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.UI.InfiniteScrollList.<LoadItemsCoreAsync>d__54.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.UI.InfiniteScrollList.<RepopulatePackageListAsync>d__50.MoveNext()
RPC server exception: Microsoft.Assumes+InternalErrorException: An internal error occurred. Please contact Microsoft Support.
at Microsoft.Assumes.Fail(String message)
at NuGet.VisualStudio.Internal.Contracts.PackageReferenceContextInfo.Create(PackageReference packageReference)
at NuGet.PackageManagement.VisualStudio.NuGetProjectManagerService.<>c.<GetInstalledPackagesAsync>b__10_2(PackageReference pr)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at NuGet.PackageManagement.VisualStudio.NuGetProjectManagerService.<GetInstalledPackagesAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
at Microsoft.ServiceHub.Framework.ServiceJsonRpcDescriptor.LocalProxyGeneration.<ReturnedValueTaskOfTHelper>d__25`1.MoveNext()
The fault is in PackageReferenceContextInfo.Create(PackageReference) because packageReference is null.
I'm surprised that NuGetProject.GetInstalledPackagesAsync(...) can return null values. Throughout NuGet code there is the assumption that the return value will be either an empty enumerable or a non-empty enumerable containing non-null values. There are a few exceptions though like in MultiSourcePackageMetadataProvider.GetLatestPackageMetadataAsync(...).
There are 8 product implementations of NuGetProject.GetInstalledPackagesAsync(...):
FolderNuGetProject.GetInstalledPackagesAsync(...)InstallCommandProject.GetInstalledPackagesAsync(...)LegacyPackageReferenceProject.GetInstalledPackagesAsync(...)MSBuildNuGetProject.GetInstalledPackagesAsync(...)NetCorePackageReferenceProject.GetInstalledPackagesAsync(...)PackagesConfigNuGetProject.GetInstalledPackagesAsync(...)ProjectJsonNuGetProject.GetInstalledPackagesAsync(...)ProjectKNuGetProject.GetInstalledPackagesAsync(...)InstallCommandProject.GetInstalledPackagesAsync(...) is only used by NuGet.exe not Visual Studio (PM UI); however, none of the implementations can return an enumerable containing null.
This is happening in one of my solutions. That one use project.json for nuget reference instead of PackageReference or package.config.
@ehasis what version of Visual Studio are you using, and what project type are you using project.json with? I don't know of any project system in Visual Studio 2019 that uses project.json.
@zivkan I'm using 16.8.3, the project type is a huge VB.NET WinForms application, but is easy to simulate with a small one. We use project.json because we have to keep compatibility with VS 2015 since couple of our colleagues still use it.
@ehasis after installing VS2015, finding the .NET Core 1.0 preview tooling and installing that, creating a sample solution with project.json and xproj, when I try to open the solution in Visual Studio 2019, I get an error saying the project is unsupported and UpgradeLog.htm says:
Xproj project files are no longer supported. For details on migrating to csproj see聽https://docs.microsoft.com/en-us/dotnet/core/migration/.
I'm not sure you're in a supported scenario. Furthermore, .NET Core didn't support WinForms until .NET Core 3.0, but the VS2015 preview tools for .NET Core only supports .NET Core 1.0. I don't understand the solution/projects you're describing. Are you able to create a new sample solution and attach it here?
@zivkan easy to reproduce, here are the steps:
{
"dependencies": {
"Newtonsoft.Json": "12.0.3"
},
"frameworks": {
"net472": {}
},
"runtimes": {
"win": {}
}
}
@dtivel @rrelyea @sbanni, using the above instructions, I tracked down the issue to this assumption being incorrect about project.json projects: https://github.com/NuGet/NuGet.Client/blob/b52bb6fe102c2a362c8adc6965cbb4c192781b1b/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/ContextInfos/PackageReferenceContextInfo.cs#L18
@ehasis, I recommend you consider moving to packages.config if you want to keep compatibility with VS2015, or move to PackageReference and drop support for VS2015 if that's more important. Project.json usage is low (0.2% of project in VS2019), so I expect we're going to drop support for it in the future. I guess in the next major version, but that decision is above my paygrade. I've marked this issue as a regression, and we're generally not allowed to regress features during the same major version of VS, so I expect this to be fixed. But setting expectations, this feature is low usage and if it causes too much technical debt, people are going to need to make tough decisions.
@ehasis, thank you very much for the repro steps! I have a fix in code review.
@dtivel I have just upgraded to version 16.8.4, but the problem is still sitting there, when will be this released?
