The Visual Studio NuGet packages (RestoreManagerPackage and NuGetPackage packages) needs to auto load on solution build events #8796
From a thread:
We had a discussion on this and decided the proper way to do this is to whitelist the SolutionBuilding UI context for sync autoload.
After the UI context is whitelisted, nuget will have to add the following into the package definition:
Note that there should be no PackageAutoLoadFlags.BackgroundLoad flag in this registration. Otherwise your package will be async autoloaded, causing the same issue. Note that you may also want to keep the existing autoload on solution exists, as that’s async autoload and helps the Build performance sometimes.