I have a small AWS EC2 Windows instance that I use for my personal usage, like hosting that blog.
When I create some small projects at home in Visual Studio 2017 Community, this is how I am able to build them on my server without installing Visual Studio on it.
First, you need to get the latest msbuild.
You can get it from Visual Studio 2017 download page. On the bottom, click “Other Tools and Frameworks”, then choose “Build Tools for Visual Studio 2017”.
Direct download link
Start that setup file (vs_buildtools_xxx.exe), and choose “Web Development Build Tools”.
After installing, you will get a new command prompt in the start menu, called “Developer Command Prompt for VS 2017”. Use it to start your command prompt, as it will add to path all required folders to run msbuild from anywhere.
Go to your folder with your solution sln file, and just type msbuild. It will automatically start building the sln files.
If you use nuget packages, you will get errors about missing packages. You may have read somewhere that you only need to type “msbuild /t:restore”, but I think that it’s only works for .NET Core solutions, it does nothing for Studio 2017 classic framework projects.
Now you need an additional file: nuget.exe, that you can find there: https://dist.nuget.org/
I use the latest version, 4.1. The download is not a setup, it’s directly the nuget executable. Only 1 file is needed.
I suggest to save it somewhere available in your path from DOS, maybe at the same place that msbuild was installed, [C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin].
Now, get back to your sln folder, and just type “nuget restore”. The “packages” folder will be created, and required nuget packages downloaded there.
You’re ready to try msbuild again.
Wow, it just works!
That was that easy.
Thanks it will be very useful for me !
I’ve found some interesting project on Github but there was no binary and lot of times they asked for a specific tools version with error like this “15.0” is unrecognized.
It’s the best article I’ve see about building project without installing the whole VST. ?
The “nuget” part is the cherry on the top ! ?
There is no new information here that can not be found on msdn. This is only useful if you are using the most recent version of the platform tool chain which is not a common use case for most shops.
You are right. I searched a solution from multiple source. I put all them together in that article. If you’re in the same context, it can help you. If you’re not, you can certainly use it as a start point to find a solution that will fit your needs!