1@echo off 2 3IF "%1%" == "" GOTO display_help 4 5SETLOCAL ENABLEDELAYEDEXPANSION 6 7SET msbuild_version=%1 8 9SET msbuild_platform=%2 10IF "%msbuild_platform%" == "" SET msbuild_platform=x64 11 12SET msbuild_configuration=%3 13IF "%msbuild_configuration%" == "" SET msbuild_configuration=Release 14 15SET msbuild_toolset=%4 16 17GOTO build 18 19:display_help 20 21echo Syntax: build.generic.cmd msbuild_version msbuild_platform msbuild_configuration msbuild_toolset 22echo msbuild_version: VS installed version (latest, VS2012, VS2013, VS2015, VS2017, VS2019, VS2022, ...) 23echo msbuild_platform: Platform (x64 or Win32) 24echo msbuild_configuration: VS configuration (Release or Debug) 25echo msbuild_toolset: Platform Toolset (v100, v110, v120, v140, v141, v142, v143, ...) 26 27EXIT /B 1 28 29:build 30 31SET msbuild="%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" 32IF %msbuild_version% == VS2013 SET msbuild="%programfiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" 33IF %msbuild_version% == VS2015 SET msbuild="%programfiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" 34IF %msbuild_version% == VS2017 SET vswhere_params=-version [15,16) -products * 35IF %msbuild_version% == VS2017Community SET vswhere_params=-version [15,16) -products Community 36IF %msbuild_version% == VS2017Enterprise SET vswhere_params=-version [15,16) -products Enterprise 37IF %msbuild_version% == VS2017Professional SET vswhere_params=-version [15,16) -products Professional 38IF %msbuild_version% == VS2019 SET vswhere_params=-version [16,17) -products * 39IF %msbuild_version% == VS2022 SET vswhere_params=-version [17,18) -products * 40REM Add the next Visual Studio version here. 41IF %msbuild_version% == latest SET vswhere_params=-latest -products * 42IF %msbuild_version% == preview SET vswhere_params=-prerelease -products * 43 44IF NOT DEFINED vswhere_params GOTO skip_vswhere 45SET vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 46FOR /F "USEBACKQ TOKENS=*" %%F IN (`%vswhere% !vswhere_params! -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) DO ( 47 SET msbuild="%%F" 48) 49:skip_vswhere 50 51SET project="%~p0\..\VS2010\zstd.sln" 52 53SET msbuild_params=/verbosity:minimal /nologo /t:Clean,Build /p:Platform=%msbuild_platform% /p:Configuration=%msbuild_configuration% 54IF NOT "%msbuild_toolset%" == "" SET msbuild_params=%msbuild_params% /p:PlatformToolset=%msbuild_toolset% 55 56SET output=%~p0%bin 57SET output="%output%/%msbuild_configuration%/%msbuild_platform%/" 58SET msbuild_params=%msbuild_params% /p:OutDir=%output% 59 60echo ### Building %msbuild_version% project for %msbuild_configuration% %msbuild_platform% (%msbuild_toolset%)... 61echo ### Build Params: %msbuild_params% 62 63%msbuild% %project% %msbuild_params% 64IF ERRORLEVEL 1 EXIT /B 1 65echo # Success 66echo # OutDir: %output% 67echo # 68