早期

适用于.net4.0

 set  MSBuild=%windir%\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe

Vs2017

 for  /f  "tokens=1,2*"  %%i  in  ( '"reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v  15.0"' )  do  ( set "Vs17=%%k" )
 
 if "%vs17%"  ==  ""  ( for  /f  "tokens=1,2*"  %%i  in  ( '"reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7" /v  15.0"' )  do  ( set "Vs17=%%k" ))
 
 
 
 set "MSBuild=%vs17%\MSBuild\15.0\Bin\MsBuild.exe" 
 

最新 vswhere

vswhere查找Msbuild

 @ echo  off
 
 setlocal enabledelayedexpansion
 
 
 
 set "VsWhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 
 
 
 for  /f  "usebackq tokens=*"  %%i  in  (` "%VsWhere%"  -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\B in \MSBuild.exe`)  do  (
 
 "%%i"  %*
 
 exit  /b !errorlevel!
 
 )

  • 打赏
  • 分享
分享到...
请选择打赏方式
  • 微信
  • 支付宝

By yhl

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注