diff --git a/Development/Scripts/Windows/CallBuildTool.bat b/Development/Scripts/Windows/CallBuildTool.bat index 1ee01db38..88821202c 100644 --- a/Development/Scripts/Windows/CallBuildTool.bat +++ b/Development/Scripts/Windows/CallBuildTool.bat @@ -2,93 +2,43 @@ rem Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. -rem Make sure the batch file exists in the root folder. -if not exist "Development\Scripts\Windows\GetMSBuildPath.bat" goto Error_BatchFileInWrongLocation - -rem Get the path to MSBuild executable. +if not exist "Development\Scripts\Windows\GetMSBuildPath.bat" goto Error_InvalidLocation call "Development\Scripts\Windows\GetMSBuildPath.bat" -if errorlevel 1 goto Error_NoVisualStudioEnvironment +if errorlevel 1 goto Error_MissingVisualStudio -rem If using VS2017, check that NuGet package manager is installed. -if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto NoVsWhere - -set MSBUILD_15_EXE= -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_15_EXE="%%i\MSBuild\%%j\Bin\MSBuild.exe" - goto FoundMsBuild15 - ) - ) -) -:FoundMsBuild15 - -set MSBUILD_15_EXE_WITH_NUGET= -for /f "delims=" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -products * -requires Microsoft.Component.MSBuild -requires Microsoft.VisualStudio.Component.NuGet -property installationPath') do ( - if exist "%%i\MSBuild\15.0\Bin\MSBuild.exe" ( - set MSBUILD_15_EXE_WITH_NUGET="%%i\MSBuild\15.0\Bin\MSBuild.exe" - goto FoundMsBuild15WithNuget - ) -) -:FoundMsBuild15WithNuget - -if not [%MSBUILD_15_EXE%] == [] ( - set MSBUILD_EXE=%MSBUILD_15_EXE% - goto NoVsWhere -) - -if not [%MSBUILD_EXE%] == [%MSBUILD_15_EXE_WITH_NUGET%] goto Error_RequireNugetPackageManager - -:NoVsWhere - -rem Check to see if the build tool source files have changed. Some can be included conditionally based on NDA access. 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_EXE% /nologo /verbosity:quiet Source\Tools\Flax.Build\Flax.Build.csproj /property:Configuration=Release /property:Platform=AnyCPU /target:Clean +%MSBUILD_PATH% /nologo /verbosity:quiet Source\Tools\Flax.Build\Flax.Build.csproj /property:Configuration=Release /property:Platform=AnyCPU /target:Clean :SkipClean -%MSBUILD_EXE% /nologo /verbosity:quiet Source\Tools\Flax.Build\Flax.Build.csproj /property:Configuration=Release /property:Platform=AnyCPU /target:Build -if errorlevel 1 goto Error_CompileFailed +%MSBUILD_PATH% /nologo /verbosity:quiet Source\Tools\Flax.Build\Flax.Build.csproj /property:Configuration=Release /property:Platform=AnyCPU /target:Build +if errorlevel 1 goto Error_CompilationFailed -rem Run the build tool using the provided arguments. Binaries\Tools\Flax.Build.exe %* if errorlevel 1 goto Error_FlaxBuildFailed - -rem Done. exit /B 0 -:Error_BatchFileInWrongLocation +:Error_InvalidLocation echo. -echo CallBuildTool ERROR: The batch file does not appear to be located in the root directory. This script must be run from within that directory. +echo CallBuildTool ERROR: The batch file is in a wrong directory. echo. goto Exit - -:Error_NoVisualStudioEnvironment +:Error_MissingVisualStudio echo. -echo CallBuildTool ERROR: We couldn't find a valid installation of Visual Studio. This program requires Visual Studio 2015. Please check that you have Visual Studio installed, then verify that the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\InstallDir (or HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\InstallDir on 32-bit machines) registry value is set. Visual Studio configures this value when it is installed, and this program expects it to be set to the '\Common7\IDE\' sub-folder under a valid Visual Studio installation directory. +echo CallBuildTool ERROR: Missing Visual Studio 2015 or newer. echo. goto Exit - -:Error_RequireNugetPackageManager -echo. -echo CallBuildTool ERROR: NuGet Package Manager is requried to be installed to use %MSBUILD_EXE%. Please run the Visual Studio Installer and add it from the individual components list (in the 'Code Tools' category). -echo. -goto Exit - -:Error_CompileFailed +:Error_CompilationFailed echo. echo CallBuildTool ERROR: Failed to compile Flax.Build project. echo. goto Exit - :Error_FlaxBuildFailed echo. echo CallBuildTool ERROR: Flax.Build tool failed. echo. goto Exit - :Exit -rem Exit with error. exit /B 1 diff --git a/Development/Scripts/Windows/GetMSBuildPath.bat b/Development/Scripts/Windows/GetMSBuildPath.bat index 8d8651719..6628384f1 100644 --- a/Development/Scripts/Windows/GetMSBuildPath.bat +++ b/Development/Scripts/Windows/GetMSBuildPath.bat @@ -2,72 +2,55 @@ rem Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. -set MSBUILD_EXE= +set MSBUILD_PATH= -rem Try to get the MSBuild 15 path using vswhere (see https://github.com/Microsoft/vswhere). -if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto no_vswhere +if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto NoVsWhere 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_EXE="%%i\MSBuild\15.0\Bin\MSBuild.exe" - goto Succeeded + set MSBUILD_PATH="%%i\MSBuild\15.0\Bin\MSBuild.exe" + goto Good ) ) -:no_vswhere - -rem Check for MSBuild 15. This is installed alongside Visual Studio 2017, so we get the path relative to that. -call :ReadInstallPath Microsoft\VisualStudio\SxS\VS7 15.0 MSBuild\15.0\bin\MSBuild.exe -if not errorlevel 1 goto Succeeded - -rem Try to get the MSBuild 14.0 path directly (see https://msdn.microsoft.com/en-us/library/hh162058(v=vs.120).aspx). +:NoVsWhere +call :GetInstallPath Microsoft\VisualStudio\SxS\VS7 15.0 MSBuild\15.0\bin\MSBuild.exe +if not errorlevel 1 goto Good if exist "%ProgramFiles(x86)%\MSBuild\14.0\bin\MSBuild.exe" ( - set MSBUILD_EXE="%ProgramFiles(x86)%\MSBuild\14.0\bin\MSBuild.exe" - goto Succeeded + set MSBUILD_PATH="%ProgramFiles(x86)%\MSBuild\14.0\bin\MSBuild.exe" + goto Good ) +call :GetInstallPath Microsoft\MSBuild\ToolsVersions\14.0 MSBuildToolsPath MSBuild.exe +if not errorlevel 1 goto Good +call :GetInstallPath Microsoft\MSBuild\ToolsVersions\12.0 MSBuildToolsPath MSBuild.exe +if not errorlevel 1 goto Good +call :GetInstallPath Microsoft\MSBuild\ToolsVersions\4.0 MSBuildToolsPath MSBuild.exe +if not errorlevel 1 goto Good -rem Try to get the MSBuild 14.0 path from the registry. -call :ReadInstallPath Microsoft\MSBuild\ToolsVersions\14.0 MSBuildToolsPath MSBuild.exe -if not errorlevel 1 goto Succeeded - -rem Check for older versions of MSBuild. These are registered as separate versions in the registry. -call :ReadInstallPath Microsoft\MSBuild\ToolsVersions\12.0 MSBuildToolsPath MSBuild.exe -if not errorlevel 1 goto Succeeded -call :ReadInstallPath Microsoft\MSBuild\ToolsVersions\4.0 MSBuildToolsPath MSBuild.exe -if not errorlevel 1 goto Succeeded - -rem Searching failed. exit /B 1 - -rem Searching done! -:Succeeded +:Good exit /B 0 -rem Subroutine to query the registry under HKCU/HKLM Win32/Wow64 software registry keys for a certain install directory. -rem Arguments: -rem %1 = Registry path under the 'SOFTWARE' registry key -rem %2 = Value name -rem %3 = Relative path under this directory to look for an installed executable. -:ReadInstallPath -for /f "tokens=2,*" %%A in ('REG.exe query HKCU\SOFTWARE\%1 /v %2 2^>Nul') do ( - if exist "%%B%%3" ( - set MSBUILD_EXE="%%B%3" - 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_EXE="%%B%3" + set MSBUILD_PATH="%%B%3" exit /B 0 ) ) -for /f "tokens=2,*" %%A in ('REG.exe query HKCU\SOFTWARE\Wow6432Node\%1 /v %2 2^>Nul') do ( +for /f "tokens=2,*" %%A in ('REG.exe query HKCU\SOFTWARE\%1 /v %2 2^>Nul') do ( if exist "%%B%%3" ( - set MSBUILD_EXE="%%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 ( if exist "%%B%3" ( - set MSBUILD_EXE="%%B%3" + set MSBUILD_PATH="%%B%3" + exit /B 0 + ) +) +for /f "tokens=2,*" %%A in ('REG.exe query HKCU\SOFTWARE\Wow6432Node\%1 /v %2 2^>Nul') do ( + if exist "%%B%%3" ( + set MSBUILD_PATH="%%B%3" exit /B 0 ) )