For a long time I have good and bad experiences of compiling a whole plethora of C# code that ranges from classic WPF to ASP .Net to UWP. Sometimes I have encountered some frustrating problems in trying to compile and build it. Some solutions could be as simple as a missing semicolon or just restart Visual Studio. Sometimes just restarting your computer or reinstalling/updating the nuget packages will do. And sometimes you might have tried everything but your compiler is still freaking out that it still cannot find this "missing" package that you're sure you've properly referenced it - double-checked, triple-checked the compiler settings and .Net versions and still won't do shit.
This happened to me a few times now and the solution that worked for me so far is:
Deleting everything inside that .nuget/Packages or Packages folder
and sometimes you might have to restart Visual Studio after doing that