How to find latest version of MsBuild in powershell

Build scripts for .net are always a bit painful, and Microsoft has not made it easy over the years as every release they change the paths. For 2017 it is even worse and it depends on the edition so they want you to use vswhere.exe to locate the installed version(s) of msbuild. I find the following bit of Powershell to be far more portable and reliable. Function Find-MsBuild([int] $MaxVersion = 2017) { $agentPath = "$Env:programfiles (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15....

September 19, 2017 · 2 min · 228 words · Alastair Crabtree