Skip to content

Package manager doesn't load for any project in the solution #1506

@yishaigalatzer

Description

@yishaigalatzer

When one of the project has a corrupt (or empty) project.json, manage packages for project UI does not load, and manage packages for solution is disabled.

Why?

In:

https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/PackageManagement.VisualStudio/IDE/VSSolutionManager.cs#L506

The solution manager tries to initialize the cache, and if it fails it catches any exception bubbling up and clears the cache. Leading to eventually trying to get NuGet Project from the cache, getting null and failing to load the window with a null ref exception.

The fun continues: in https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/PackageManagement.VisualStudio/IDE/NuGetAndEnvDTEProjectCache.cs#L224

Individual projects are being added, but if one of them fails for any reason the whole operation fails, leading to an empty cache.

In this case the following constructor fails because it can't read the json file
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/PackageManagement.VisualStudio/VSNuGetProjectFactory.cs#L80

Finally -

This line
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/VsExtension/NuGetPackage.cs#L642

Returns null leading to

https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/VsExtension/NuGetPackage.cs#L647

Throwing

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions