I've looked at a ton of articles on this including here and here. None provide a solution that I can get to work.
I have everything turned on for automatically doing this in VisualStudio. But on our build machine we build the .sln files using MSBuild, not by opening up VisualStudio. So in MSBuild how can I best do this?
All of our .sln files are for VisualStudio 2019 and set to defaults on handling NuGet (I believe).
msbuild -t:Restore
will restore nuget packages for projects with PackageReference nuget management format.
And your situation looks like packages.config nuget management format which you have used it.
If so, you only should use nuget restore
to restore nuget packages with msbuild.exe.
1) first download nuget.exe cli
from the website and config it. You can check this about it.
2) then use MSBuild command line, type
nuget xxx\xxx.sln restore
msbuild xxx\xxx.sln -t:build
Another is to use msbuild -t:restore with -p:RestorePackagesConfig=true
.
msbuild xxx\xxx.sln -t:build -restore -p:RestorePackagesConfig=true