bpo-30687: Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat (#2252)
* Fixes build scripts to find msbuild.exe and stop relying on vcvarsall.bat
Also fixes bdist_wininst.vcxproj to use correct version in generated name.
diff --git a/Tools/msi/build.bat b/Tools/msi/build.bat
index 59e0261..f720ea9 100644
--- a/Tools/msi/build.bat
+++ b/Tools/msi/build.bat
@@ -22,8 +22,8 @@
if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
call "%D%get_externals.bat"
-
-call "%PCBUILD%env.bat" x86
+call "%PCBUILD%find_msbuild.bat" %MSBUILD%
+if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2)
if defined BUILDX86 (
call "%PCBUILD%build.bat" -d -e %REBUILD% %BUILDTEST%
@@ -44,7 +44,7 @@
)
rem Build the launcher MSI separately
-msbuild "%D%launcher\launcher.wixproj" /p:Platform=x86
+%MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86
set BUILD_CMD="%D%bundle\snapshot.wixproj"
if defined BUILDTEST (
@@ -58,11 +58,11 @@
)
if defined BUILDX86 (
- msbuild %BUILD_CMD%
+ %MSBUILD% %BUILD_CMD%
if errorlevel 1 goto :eof
)
if defined BUILDX64 (
- msbuild /p:Platform=x64 %BUILD_CMD%
+ %MSBUILD% /p:Platform=x64 %BUILD_CMD%
if errorlevel 1 goto :eof
)
diff --git a/Tools/msi/buildrelease.bat b/Tools/msi/buildrelease.bat
index c432c39..e55d81a 100644
--- a/Tools/msi/buildrelease.bat
+++ b/Tools/msi/buildrelease.bat
@@ -69,6 +69,8 @@
if not exist "%GIT%" echo Cannot find Git on PATH && exit /B 1
call "%D%get_externals.bat"
+call "%PCBUILD%find_msbuild.bat" %MSBUILD%
+if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2)
:builddoc
if "%SKIPBUILD%" EQU "1" goto skipdoc
@@ -165,28 +167,27 @@
@echo off
)
-call "%PCBUILD%env.bat"
if "%OUTDIR_PLAT%" EQU "win32" (
- msbuild "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI%
+ %MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI%
if errorlevel 1 exit /B
) else if not exist "%PCBUILD%win32\en-us\launcher.msi" (
- msbuild "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI%
+ %MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI%
if errorlevel 1 exit /B
)
set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI%
-msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true
+%MSBUILD% "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true
if errorlevel 1 exit /B
-msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false
+%MSBUILD% "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false
if errorlevel 1 exit /B
if defined BUILDZIP (
- msbuild "%D%make_zip.proj" /t:Build %BUILDOPTS% %CERTOPTS% /p:OutputPath="%BUILD%en-us"
+ %MSBUILD% "%D%make_zip.proj" /t:Build %BUILDOPTS% %CERTOPTS% /p:OutputPath="%BUILD%en-us"
if errorlevel 1 exit /B
)
if defined BUILDNUGET (
- msbuild "%D%..\nuget\make_pkg.proj" /t:Build /p:Configuration=Release /p:Platform=%1 /p:OutputPath="%BUILD%en-us"
+ %MSBUILD% "%D%..\nuget\make_pkg.proj" /t:Build /p:Configuration=Release /p:Platform=%1 /p:OutputPath="%BUILD%en-us"
if errorlevel 1 exit /B
)
diff --git a/Tools/msi/uploadrelease.bat b/Tools/msi/uploadrelease.bat
index 0873d55..610b092 100644
--- a/Tools/msi/uploadrelease.bat
+++ b/Tools/msi/uploadrelease.bat
@@ -49,16 +49,17 @@
echo Found gpg2.exe at %GPG%
)
-call "%PCBUILD%env.bat" > nul 2> nul
+call "%PCBUILD%find_msbuild.bat" %MSBUILD%
+if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2)
pushd "%D%"
-msbuild /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86 %PURGE_OPTION%
-msbuild /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false %PURGE_OPTION%
+%MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86 %PURGE_OPTION%
+%MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false %PURGE_OPTION%
if not defined NOTEST (
- msbuild /v:m /nologo uploadrelease.proj /t:Test /p:Platform=x86
- msbuild /v:m /nologo uploadrelease.proj /t:Test /p:Platform=x64
+ %MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=x86
+ %MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=x64
)
-msbuild /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x86
-msbuild /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x64 /p:IncludeDoc=false
+%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x86
+%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x64 /p:IncludeDoc=false
popd
exit /B 0
diff --git a/Tools/nuget/build.bat b/Tools/nuget/build.bat
index 5068c17..54498ca 100644
--- a/Tools/nuget/build.bat
+++ b/Tools/nuget/build.bat
@@ -21,7 +21,8 @@
if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
call "%D%..\msi\get_externals.bat"
-call "%PCBUILD%env.bat" x86
+call "%PCBUILD%find_msbuild.bat" %MSBUILD%
+if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2)
if defined PACKAGES set PACKAGES="/p:Packages=%PACKAGES%"
@@ -30,7 +31,7 @@
) else if not exist "%PCBUILD%win32\python.exe" call "%PCBUILD%build.bat" -e
if errorlevel 1 goto :eof
- msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x86 %OUTPUT% %PACKAGES%
+ %MSBUILD% "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x86 %OUTPUT% %PACKAGES%
if errorlevel 1 goto :eof
)
@@ -39,7 +40,7 @@
) else if not exist "%PCBUILD%amd64\python.exe" call "%PCBUILD%build.bat" -p x64 -e
if errorlevel 1 goto :eof
- msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x64 %OUTPUT% %PACKAGES%
+ %MSBUILD% "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x64 %OUTPUT% %PACKAGES%
if errorlevel 1 goto :eof
)