From 648fd5c9d6f7e6eaae620029135bc376f85fc11d Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Fri, 12 Apr 2019 21:16:59 -0700 Subject: [PATCH] Fixes Build.cmd if VS2019 is also installed on the system. (#553) * Fixes Build.cmd if VS2019 is also installed on the system. * Using vswhere to find msbuild in Build.cmd. * Suggestions to make the PR not use a temp file and optionally use MSBuild 16 --- Build.cmd | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Build.cmd b/Build.cmd index 52fcb29942..206fb0f16d 100644 --- a/Build.cmd +++ b/Build.cmd @@ -96,6 +96,11 @@ if "%1" == "/project" ( shift goto :MoreArguments ) +if "%1" == "/usevsprerelease" ( + set VSWHEREPARAMS=%VSWHEREPARAMS% -prerelease + shift + goto :MoreArguments +) if "%1" NEQ "" ( echo ERROR: Unknown argument "%1" goto :usage @@ -104,13 +109,20 @@ goto :DoBuild :DoBuild +for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest %VSWHEREPARAMS% -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do ( + set MSBUILDPATH=%%i + set MSBUILDDIRPATH=%%~dpi + IF !MSBUILDDIRPATH:~-1!==\ SET MSBUILDDIRPATH=!MSBUILDDIRPATH:~0,-1! + echo Using MSBuild from !MSBUILDPATH! in !MSBUILDDIRPATH! +) + REM REM NUGET Restore REM if "%PROJECTPATH%" NEQ "" ( - call .\Tools\NugetWrapper.cmd restore -NonInteractive %PROJECTPATH% + call .\Tools\NugetWrapper.cmd restore -MSBuildPath "%MSBUILDDIRPATH%" -NonInteractive %PROJECTPATH% ) else ( - call .\Tools\NugetWrapper.cmd restore -NonInteractive .\MUXControls.sln + call .\Tools\NugetWrapper.cmd restore -MSBuildPath "%MSBUILDDIRPATH%" -NonInteractive .\MUXControls.sln ) REM @@ -125,22 +137,19 @@ if "%USEINSIDERSDK%" == "1" ( set EXTRAMSBUILDPARAMS=/p:UseInsiderSDK=true ) if "%USEINTERNALSDK%" == "1" ( set EXTRAMSBUILDPARAMS=/p:UseInternalSDK=true ) if "%EMITTELEMETRYEVENTS%" == "1" ( set EXTRAMSBUILDPARAMS=/p:EmitTelemetryEvents=true ) -REM Need an explicit full path to MSBuild.exe or it will fall back to 14.0 for some reason -set MSBUILDPATH=%VSINSTALLDIR%\MSBuild\15.0\Bin\MSBuild.exe - if "%PROJECTPATH%" NEQ "" ( - set MSBuildCommand="%MSBUILDPATH%" %PROJECTPATH% /p:platform="%BUILDPLATFORM%" /p:configuration="%BUILDCONFIGURATION%" /p:VisualStudioVersion="15.0" /flp:Verbosity=Diagnostic /fl /bl %EXTRAMSBUILDPARAMS% /verbosity:Minimal + set MSBuildCommand="%MSBUILDPATH%" %PROJECTPATH% /p:platform="%BUILDPLATFORM%" /p:configuration="%BUILDCONFIGURATION%" /flp:Verbosity=Diagnostic /fl /bl %EXTRAMSBUILDPARAMS% /verbosity:Minimal echo !MSBuildCommand! !MSBuildCommand! ) else ( if "%BUILDALL%" == "" ( set XES_OUTDIR=%BUILD_BINARIESDIRECTORY%\%BUILDCONFIGURATION%\%BUILDPLATFORM%\ - "%MSBUILDPATH%" .\MUXControls.sln /p:platform="%BUILDPLATFORM%" /p:configuration="%BUILDCONFIGURATION%" /p:VisualStudioVersion="15.0" /flp:Verbosity=Diagnostic /fl /bl %EXTRAMSBUILDPARAMS% /verbosity:Minimal + "%MSBUILDPATH%" .\MUXControls.sln /p:platform="%BUILDPLATFORM%" /p:configuration="%BUILDCONFIGURATION%" /flp:Verbosity=Diagnostic /fl /bl %EXTRAMSBUILDPARAMS% /verbosity:Minimal if "%ERRORLEVEL%" == "0" call .\tools\MakeAppxHelper.cmd %BUILDPLATFORM% %BUILDCONFIGURATION% ) else ( - "%MSBUILDPATH%" .\build\BuildAll.proj /maxcpucount:12 /p:VisualStudioVersion="15.0" /flp:Verbosity=Diagnostic /fl /bl /verbosity:Minimal + "%MSBUILDPATH%" .\build\BuildAll.proj /maxcpucount:12 /flp:Verbosity=Diagnostic /fl /bl /verbosity:Minimal if "%ERRORLEVEL%" == "0" ( call .\tools\MakeAppxHelper.cmd x86 release @@ -182,6 +191,7 @@ echo /UseInsiderSDK - build using insider SDK echo /UseInternalSDK - build using internal SDK echo /EmitTelemetryEvents - build with telemetry events turned on echo /project ^ - builds a specific project +echo /usevsprerelease - use the prerelease VS on the machine instead of latest stable echo. :end