I rarely have issues with NuGet. After adding references, it just works.
Recently though I had a frustrating issue with “missing / restored” packages not being included in the build.
Problem
After several code merges from the team, Visual Studio 2022 kept reporting this error:
The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see: http://go.microsoft.com/fwlink/?LinkID=317568. {solution} {path} {project_name}.csproj 3824
I made sure these settings were enabled via Tools -> Options:
I checked VS references. No missing references:
I also rebuilt and cleaned the solution and individual projects each time. No luck.
Solution
In the end, the Package Manager Console resolved the issue.
Specifically, this command:
Update-Package -reinstall
A bit strange. I expected the Package Restore settings in Visual Studio to automatically handled restoration of any missing NuGet packages (earlier screenshot).
Learn more about this command here.
Chip
hmmm – getting this error using the command above:
The `-Reinstall` parameter does not apply to PackageReference based projects
OHNO
Windows and Visual Studo are a nightmare now.