'Restore NuGet packages failed for project ... : Could not find a part of the path
I'm trying to run a Unit Test project in Visual Studio (.NET Framework 4.72).
The project is now building/running successfully, however there is still an error that the NuGet packages can't be restored (the file path is actually wrong and does not exist.). How can I change to the right file path and tell VS to not look in the wrong path? Here's the error:
NuGet Package restore failed for project Tests_WeatherData: Could not find a part of the path 'C:......\Begin\packages\MSTest.TestAdapter.1.3.2\build/_common/zh-Hans/Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources.dll'
Thank you for any advice how to change the file path/restoring settings.
Solution 1:[1]
It can be caused by having your project located within a subfolder that is too deeply nested. I think possibly there's some limit for the folder path like maybe 250 characters or something like that.
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.
Solution 2:[2]
The issue could be filepaths in your CSPROJ file. Most common cause is project restructure and the location of packages has changed.
In addition to NUGET references in the CSPROJ, there could be a few other spots in the footer of the CSPROJ or the header portion for MSTest adapter entries. I.e. just verify all your filepaths (especially relative) ones are all correct and reload/rebuild.
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 |
| Solution 2 | HouseCat |
