Unable to find nuget local source error occurred while restoring nuget packages the local source doesn't exist

前端 未结 5 1108
说谎
说谎 2021-02-12 05:57

I\'ve been given a visual studio 2017 solution. When I open it fails as with the error:

Error occurred while restoring NuGet packages: The local source \'\\\\netw

相关标签:
5条回答
  • 2021-02-12 06:29

    The package sources can be found in the Visual Studio options (Tools -> Options) under NuGet Package Manager -> Package Sources or directly by clicking on the according icon in the NuGet dialog (context menu of a solution/project -> Manage NuGet Packages...):

    Your local package source should then be listed in the following dialog:

    The package source may, however, be solution or project specific and may therefore be specified in a NuGet.config file in the solution directory. Beginning with NuGet 3.4, Visual Studio looks in the project's directory or "or any folder up to the drive root", according to the NuGet.config reference. Up to NuGet 3.3, also subdirectories with the name .nuget where searched for NuGet.config files.

    The file containing your local package source must be changed in order to restore the correct packages.

    0 讨论(0)
  • 2021-02-12 06:41

    I had this error in different situation. I checked contents of Nuget.config in my solution folder and under <packageSources> node it had an entry pointing to ./nuget. This folder didn't exist in the solution directory, so I just created an empty folder with this name and the solution compiled without any problems.

    0 讨论(0)
  • 2021-02-12 06:49

    In my case i have getting this error: Error occurred while restoring NuGet packages: The local source 'C:\Microsoft\Xamarin\NuGet' doesn't exist.

    I have accidentally deleted 'C:\Microsoft\Xamarin\' folder. After this VS2019 was not able to restore packages. I just manually created 'C:\Microsoft\Xamarin\NuGet' folder. Restarted VS, cleaned solution and everything goes well after this.

    0 讨论(0)
  • 2021-02-12 06:51

    Nothing of the proposed solutions above did it for me. And, honestly, I really don't like, what Microsoft is doing for some time now: each time there's another surprise when installing an update. :-(

    Analysis:

    Error occurred while restoring NuGet packages: The local source 'C:\Microsoft\Xamarin\NuGet' doesn't exist.
    

    Obviously NuGet is trying to restore from C:\\Microsoft\\Xamarin\\NuGet for s solution that has nothing to do with Xamarin. The solution compiled many times before and even getting it back from GIT did not change anything. So, the problem is not my solution. It is something more global.

    By the way: I DONT WANT TO USE THIS FOLDER, cause I don't use Xamarin!

    I found the following reference in the *.csproj.nuget.dgspec.json files in any obj folder of my solution. All these json files pointed to this Xamarin folder:

    "fallbackFolders": {
      "C:\\Microsoft\\Xamarin\\NuGet": {},  
      "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
      "https://api.nuget.org/v3/index.json": {}
    },
    

    Question: How does VS know about the fallbackFolders?

    I did not find any hint in any of my Visual Studio / NuGet configuration settings, as proposed above. I deleted all objfolder but each time when trying to compile or restore my packages, the reference came back.

    The SOLUTION for me was :

    • delete all objfolders in your solution (as mentioned above)

    • delete c:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config

    There you will find the following:

    <fallbackPackageFolders>
        <add key="Xamarin Offline Packages" value="C:\Microsoft\Xamarin\NuGet\"/>
    </fallbackPackageFolders>
    

    This file was introduced on my machine one week ago, and I think it came with the latest VS update (16.2). I did not go away with the latest update (16.2.1) from today.

    0 讨论(0)
  • 2021-02-12 06:54

    You will encounter the same issue in Visual Studio 2019. I have the same issue, I thought it was a conflict on Visual Studio 2017 but it wasn't.

    The fix is you have to remove the source that is causing the issue.

    You can remove it via Tools -> NuGet Package Manager -> Package Manager Settings

    0 讨论(0)
提交回复
热议问题