Note: I have already read How can I install the VS2017 version of msbuild on a build server without installing the IDE? but this does not answer with a totally GUI-less script-only install.
Along the years, here is what I noticed:
I download a project from Github ; or open an old project of mine (say from 4 years ago)
run
msbuild.exe theproject.sln
oops, I don't have the right Visual Studio version / .NET Framework version / the right SDK is missing (example situation here among many others)
then spend X hours browsing on websites like https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019, install a package, then notice it's not the right one (
msbuild
still fails), download another package, install it, etc.at the end you have downloaded 8 GB of packages, waited for the download, waited for the install, for the reboot, and you're still not sure it works
your computer is now a mess with 5 different versions of SDKs installed at the same time that probably collide with each other (did version Z overwrite/uninstall version Y or not?)
This might be a solution to avoid this problem:
How to install the required MS build tools from command-line? (I don't want to use any IDE, I want to script everything)
If it was possible, I would just, once for all create a build.bat
file for every project, that would be something like:
msbuildget --package=VC14 --installdir=c:\buildtools\vc14 # automatically download and install
C:\buildtools\vc14\bin\msbuild.exe myproject.sln
or
msbuildget --package=.NET-35 --installdir=c:\buildtools\net35
C:\buildtools\net35\bin\msbuild.exe myproject.sln
How to do this?
With this method, even if you open a 6-year old project, you should be able to build it.