Skip to content

Commit

Permalink
Fixes Build.cmd if VS2019 is also installed on the system. (#553)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
azchohfi authored and msft-github-bot committed Apr 13, 2019
1 parent 4a94f1e commit 648fd5c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ^<path^> - builds a specific project
echo /usevsprerelease - use the prerelease VS on the machine instead of latest stable
echo.

:end
Expand Down

0 comments on commit 648fd5c

Please sign in to comment.