Accidentally cleared NuGet folders, now project won't Build at all

I may have made a huge mistake.

 

When building my current Project (an Android app built with Xamarin), I had a warning popping up that told me I had two versions of System.Numerics.Vectors installed which were incompatible. Didn't create me any problems, but I tried to fix it anyway by messing around with the NuGet package manager, uninstalling and reinstalling that package several times.

I then switched to the "Folders" tab of the NuGet package manager, and foolishly clicked "Clear all selected caches" while having ALL FOLDERS SELECTED. In retrospect, very foolish, but hindsight is 20/20.

My project will now not build, and gives me a big red error message like this:

  Xamarin.AndroidX.Migration.targets(131, 9): [MSB4018] The "ValidateAndroidXPackages" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\DarkAndDusty\.nuget\packages\xamarin.androidx.migration\1.0.10\buildTransitive\monoandroid120\Tools\Mappings\androidx-assemblies.csv'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Xamarin.AndroidX.Migration.CsvMapping.LoadMapping(String mappingFile)
   at Xamarin.AndroidX.Migration.AndroidXAssembliesCsvMapping..ctor()
   at Xamarin.AndroidX.Migration.BuildTasks.ValidateAndroidXPackages.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

I have no idea what it means, I tried redownloading every AndroidX package I remembered my project had (not many), but the error will not go away no matter what I do.

I'm lost on what to do, I've even tried to recreate the path and file it tells me a part of is not available (C:\Users\DarkAndDusty\.nuget\packages\xamarin.androidx.migration\1.0.10\buildTransitive\monoandroid120\Tools\Mappings\androidx-assemblies.csv'.), and the project seems to build, but will fail to connect to the Debugger, and major features of the program do not appear to work.

If you understand what's going on or have any idea about what to do, can you please point me in the right direction? If there's any information that I didn't provide which you need, I'll gladly do so.

2 comments
Comment actions Permalink

I've managed to fix the issue of the "ValidateXAndroidPackages task failed unexpectedly", putting the solution here for reference by anyone running into the same problem (although I hope no one will).

The solution that worked for me is to go into the C:\Users\<Username>\.nuget\packages folder, and find the "xamarin.androidx.migration" folder. Then rename this folder into something different, I renamed it "xamarin.androidx.migration.backup", but likely whatever else also works.

Finally, try to build / rebuild the project. It should work without that error, and will generate a new folder "xamarin.androix.migration" with the proper files.

0
Comment actions Permalink

Hi! 

I'm happy you've managed to find the solution. Thank you for adding it here! 

However, this case also looks like a bug. I was able to reproduce it and created an issue for this. Feel free to follow! Should you have any other questions, let us know. Have a great day! 

0

Please sign in to leave a comment.