I am following this tutorial for creating a custom Visual Studio extension. I just installed the Visual Studio extension development workload, and I'm using Visual Studio 2022 version 17.12.
I just finished the step Add a custom command and I'm trying to fix compilation errors. One says Local source 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages' does not exist.
If I go to Tools > Options > NuGet Package Manager, this is what I see:
The selected path exists. All I know is that the path that appears in the error message is the one described by the "fallback config", but I don't know why that would point to a non-existent path.
Can someone help me understand what's going on and how to fix this error? I don't know much about NuGet.
From looking at your error message, looks like that Visual Studio is trying to access a local NuGet package source that doesn't exist on your machine. For this issue, here are suggestions you can troubleshoot:
Please check if the path C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages
exists on your machine. Looks like it's different from the path C:\Program Files (x86)\Microsoft SDKs\NuGetPackages
in your Package Sources. If it does not exist, create C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages
directory.
The package source is defined in Nuget.config
file(Windows: %appdata%\NuGet\NuGet.Config).You should see under a package sources element an add element that adds that file path. Comment out or delete that line.
<packageSources>
<add key="local" value="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" />
</packageSources>
You can also go to Tools > Options > NuGet Package Manager
Under Package Sources, find the entry for C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages
and remove it or update it to a valid path.
After doing that, run dotnet restore --verbosity normal
to restore your packages.