Recently I've cloned a quite large solution from a GIT repository and restored NuGet packages by right-clicking the solution and selecting "Restore NuGet Packages" from the list:

NuGet restore went fine:

But when I built the solution, I've got lots of "missing reference" warnings:

And build errors like this:

Invalid option '7.3' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.

To fix this, you can close the Visual Studio, delete the hidden .vs folder, open the solution in Visual Studio again, do Clean Solution, and Rebuild after that.

It's a bit of work, so I prefer to do first-time builds using MSBuild instead.

Environment Variables

Make sure MSBuild and Nuget Commandline are inside your Path:

NuGet Commandline can be downloaded from the following link:

MSBuild for Visual Studio 2019 is located here:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin

Building solution from the command line

Now you can build your solutions from the command line like this.

Nuget restore:

nuget restore MySolution.sln

Building the solution:

msbuild MySolution.sln /t:build /m

/m will speed up your builds by telling MSBuild to use several cores.

NOTE: Replace MySolution.sln with your solution name

And that's it! No more warnings or build errors.