If you need just to compile a program, you need to do just this:
MSBuild MySolution.SLN
The only problem would be to find an appropriate MSBuild.EXE version, depending on the solution. This is a part of .NET framework, not Visual Studio.
These are typical path names matching the version of the SLN file format
SLN format version: 9.0
Supported .NET Framework: 2.0 (only)
VS Version: VS 2005
Path: %windir%\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
SLN format version: 10.00
Supported .NET Framework: 2.0, 3.0, 3.5
VS Version: 2008
Path: %windir%\Microsoft.NET\Framework\v3.5\MSBuild.exe
SLN format version: 11.00
Supported .NET Framework: 2.0, 3.0, 3.5, 4.0
VS Version: VS 2010
Path: %windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
—SA