'Visual studio 2019 Google test nuget package restore failing

I have this error when I try to open some students' assignments in Visual Studio 2019, stating that nuget can't restore a package. I'm concerned about the direction of the slashes, but have no idea how to fix this. The package is googletest. It says to look at the Error list window, but unfortunately, this is the Error list window.

The error information is;

Severity Code Description Project File Line Suppression State Error NuGet Package restore failed for project MathsLib-test: Could not find a part of the path 'Y:\test\AMF-2022\Assignment2\submissions\s1\s1\MathsLib_Start1\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.4\build/native/Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets'.. Please see Error List window for detailed warnings and errors.



Solution 1:[1]

It can be caused by having your project located within a subfolder that is too deeply nested. Possibly there's some limit for the folder path length?

I saw the same error when I downloaded a zip with some demo projects and when I unzipped it created a folder with many subfolders. The project I was interested in was down pretty deep in the subfolders and when I tried to restore its NuGet packages I got the same errors.

I moved the project folder up nearer to c:\ and then the restore errors went away.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gary Barrett