Error occurred while restoring NuGet packages: The operation failed as details for project ClassLibrary1 could not be loaded. #8813
Labels
Functionality:Restore
Resolution:Duplicate
This issue appears to be a Duplicate of another issue
Style:PackageReference
Type:Bug
Details about Problem
Open attached solution in Visual Studio
and try to compile it. It will create an error message during build
'Error occurred while restoring NuGet packages: The operation failed
as details for project ClassLibrary1 could not be loaded.'
The reason is that it has two targets and a assembly name that changes
depending on target version. This causes an InvalidOperationException
in VsNominationUtilities ~Line 300:
GetNonEvaluatedPropertyOrNull(values, propertyName, valueFactory).SingleOrDefault()
that is invoked by
internal static string GetPackageId(ProjectNames projectNames, IEnumerable tfms)
as two package ID's are resolved (one for each assembly name).
This further causes that no restore entry is created in the project
system cache and then will cause this build error.
Detailed repro steps so we can see the same problem
Other suggested things
A workaround is to set an explicit 'PackageId' for ClassLibrary1.
But it took me one day of debugging the NuGet extension to find that IMO workaround.
So some fix, or at least better log output when the cache entry cannot be created would
be nice. If i saw correctly, the exception during cache creation is simply swallowed
(at least in normal builds without special logging enabled etc.) and
and creates followup issues later. Very annoying.
Sample Project
ConsoleApp27.zip
The text was updated successfully, but these errors were encountered: