MSBuild and package restore with packages.config

Solution 1:

https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target

MSBuild 16.5+ also has opt-in support for the packages.config format.

Use:

msbuild -p:RestorePackagesConfig=true -t:restore
msbuild -t:build

Solution 2:

According to documentation[1]:

The restore target works only for projects using the PackageReference format. It does not work for projects using the packages.config format; use nuget restore instead.

So you will have to use nuget.exe restore instead. Look my other answer for that.

[1] https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets