From 0f18fd96109e3041077d90acee57c6b36988a259 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 21 Dec 2020 23:46:59 +0100 Subject: [PATCH] Fix build scripts --- Development/Scripts/Windows/CallBuildTool.bat | 21 ++++++++--- .../Scripts/Windows/GetMSBuildPath.bat | 36 ++++++++++--------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Development/Scripts/Windows/CallBuildTool.bat b/Development/Scripts/Windows/CallBuildTool.bat index 88821202c..021eeeed2 100644 --- a/Development/Scripts/Windows/CallBuildTool.bat +++ b/Development/Scripts/Windows/CallBuildTool.bat @@ -3,13 +3,26 @@ rem Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. if not exist "Development\Scripts\Windows\GetMSBuildPath.bat" goto Error_InvalidLocation -call "Development\Scripts\Windows\GetMSBuildPath.bat" -if errorlevel 1 goto Error_MissingVisualStudio +call "Development\Scripts\Windows\GetMSBuildPath.bat" +if errorlevel 1 goto Error_NoVisualStudioEnvironment + +if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto Compile +for /f "delims=" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath') do ( + for %%j in (15.0, Current) do ( + if exist "%%i\MSBuild\%%j\Bin\MSBuild.exe" ( + set MSBUILD_PATH="%%i\MSBuild\%%j\Bin\MSBuild.exe" + goto Compile + ) + ) +) + +:Compile md Cache\Intermediate >nul 2>nul dir /s /b Source\Tools\Flax.Build\*.cs >Cache\Intermediate\Flax.Build.Files.txt fc /b Cache\Intermediate\Build\Flax.Build.Files.txt Cache\Intermediate\Build\Flax.Build.PrevFiles.txt >nul 2>nul if not errorlevel 1 goto SkipClean + copy /y Cache\Intermediate\Build\Flax.Build.Files.txt Cache\Intermediate\Build\Flax.Build.PrevFiles.txt >nul %MSBUILD_PATH% /nologo /verbosity:quiet Source\Tools\Flax.Build\Flax.Build.csproj /property:Configuration=Release /property:Platform=AnyCPU /target:Clean :SkipClean @@ -22,10 +35,10 @@ exit /B 0 :Error_InvalidLocation echo. -echo CallBuildTool ERROR: The batch file is in a wrong directory. +echo CallBuildTool ERROR: The script is in invalid directory. echo. goto Exit -:Error_MissingVisualStudio +:Error_NoVisualStudioEnvironment echo. echo CallBuildTool ERROR: Missing Visual Studio 2015 or newer. echo. diff --git a/Development/Scripts/Windows/GetMSBuildPath.bat b/Development/Scripts/Windows/GetMSBuildPath.bat index 6628384f1..6eaf3af4f 100644 --- a/Development/Scripts/Windows/GetMSBuildPath.bat +++ b/Development/Scripts/Windows/GetMSBuildPath.bat @@ -4,45 +4,41 @@ rem Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. set MSBUILD_PATH= -if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto NoVsWhere +if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto VsWhereNotFound for /f "delims=" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath') do ( if exist "%%i\MSBuild\15.0\Bin\MSBuild.exe" ( set MSBUILD_PATH="%%i\MSBuild\15.0\Bin\MSBuild.exe" - goto Good + goto End ) ) -:NoVsWhere -call :GetInstallPath Microsoft\VisualStudio\SxS\VS7 15.0 MSBuild\15.0\bin\MSBuild.exe -if not errorlevel 1 goto Good +:VsWhereNotFound + if exist "%ProgramFiles(x86)%\MSBuild\14.0\bin\MSBuild.exe" ( set MSBUILD_PATH="%ProgramFiles(x86)%\MSBuild\14.0\bin\MSBuild.exe" - goto Good + goto End ) + +call :GetInstallPath Microsoft\VisualStudio\SxS\VS7 15.0 MSBuild\15.0\bin\MSBuild.exe +if not errorlevel 1 goto End call :GetInstallPath Microsoft\MSBuild\ToolsVersions\14.0 MSBuildToolsPath MSBuild.exe -if not errorlevel 1 goto Good +if not errorlevel 1 goto End call :GetInstallPath Microsoft\MSBuild\ToolsVersions\12.0 MSBuildToolsPath MSBuild.exe -if not errorlevel 1 goto Good +if not errorlevel 1 goto End call :GetInstallPath Microsoft\MSBuild\ToolsVersions\4.0 MSBuildToolsPath MSBuild.exe -if not errorlevel 1 goto Good +if not errorlevel 1 goto End exit /B 1 -:Good +:End exit /B 0 :GetInstallPath -for /f "tokens=2,*" %%A in ('REG.exe query HKLM\SOFTWARE\%1 /v %2 2^>Nul') do ( - if exist "%%B%3" ( - set MSBUILD_PATH="%%B%3" - exit /B 0 - ) -) for /f "tokens=2,*" %%A in ('REG.exe query HKCU\SOFTWARE\%1 /v %2 2^>Nul') do ( if exist "%%B%%3" ( set MSBUILD_PATH="%%B%3" exit /B 0 ) ) -for /f "tokens=2,*" %%A in ('REG.exe query HKLM\SOFTWARE\Wow6432Node\%1 /v %2 2^>Nul') do ( +for /f "tokens=2,*" %%A in ('REG.exe query HKLM\SOFTWARE\%1 /v %2 2^>Nul') do ( if exist "%%B%3" ( set MSBUILD_PATH="%%B%3" exit /B 0 @@ -54,4 +50,10 @@ for /f "tokens=2,*" %%A in ('REG.exe query HKCU\SOFTWARE\Wow6432Node\%1 /v %2 2^ exit /B 0 ) ) +for /f "tokens=2,*" %%A in ('REG.exe query HKLM\SOFTWARE\Wow6432Node\%1 /v %2 2^>Nul') do ( + if exist "%%B%3" ( + set MSBUILD_PATH="%%B%3" + exit /B 0 + ) +) exit /B 1