Windows 10中Visual Studio 2017使用Xamarin时无法找到包的问题
It looks like your NuGet package manager is having trouble locating the required Xamarin packages—this is a common hiccup when package sources are misconfigured, the cache is corrupted, or offline mode is accidentally enabled. Let’s walk through practical fixes step by step:
Verify and Correct Package Sources
OpenTools > NuGet Package Manager > Package Manager Settings. Under thePackage Sourcessection:- Make sure
nuget.orgis listed and enabled. If it’s missing, add it manually with the source URLhttps://api.nuget.org/v3/index.json. - Disable any unused or outdated sources (like old offline repositories) that might be interfering with package lookup. Stick to reliable sources like nuget.org for now.
- Make sure
Disable Offline Mode
Sometimes Visual Studio gets stuck in offline mode, blocking access to online packages:- In the same Package Manager Settings, navigate to
Generaland ensure both "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" are checked. - You can also confirm status in the Package Manager Console: run
Get-PackageSourceto see if any source showsIsOfflineasTrue. If so, toggle it off withSet-PackageSource -Name "nuget.org" -IsOffline $false.
- In the same Package Manager Settings, navigate to
Clear Corrupted NuGet Cache
Damaged cache files often cause package lookup failures:- Go to
Tools > Options > NuGet Package Manager > Generaland click "Clear All NuGet Cache(s)". - Alternatively, close Visual Studio and manually delete the cache folder at
%userprofile%\.nuget\packages.
- Go to
Repair Your Visual Studio Installation
If Xamarin components were installed incorrectly or corrupted:- Open the Visual Studio Installer, select your VS2017 instance, click "Modify" then "Repair". This will re-install any missing mobile development components and fix broken Xamarin-related files.
Manually Install Missing Packages
If all else fails, add the packages directly to your solution:- Right-click your solution >
Manage NuGet Packages for Solution. - Go to the Browse tab, search for
Xamarin.Formsand install it to all projects in your solution. Repeat this process for the missingXamarin.Android.Support.v7packages.
- Right-click your solution >
After each step, rebuild your project to check if the errors resolve. If issues persist, make sure your NuGet Package Manager extension is up to date (check Tools > Extensions and Updates for available updates).
内容的提问来源于stack exchange,提问作者Raúl Cuadrado

