From 65144f08dc3f5cd4dbcfb1877224a5cdb1ed51cf Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 24 Mar 2021 21:02:56 +0800 Subject: [PATCH 1/3] add 14.27toolchain to vs2019 installation fix command fix logic Use 19.28 instead fix install args Update VS configuration script Fix vs2019 script Fix env update script Remove double quotes --- conda/vs2019/activate.bat | 4 +++ windows/internal/check_deps.bat | 6 ++++ windows/internal/vc_install_helper.bat | 20 +++++++++++++ windows/internal/vs2019_install.ps1 | 41 ++++++++++++++++++++++---- 4 files changed, 66 insertions(+), 5 deletions(-) diff --git a/conda/vs2019/activate.bat b/conda/vs2019/activate.bat index 6f607ba75..5fa75ce93 100644 --- a/conda/vs2019/activate.bat +++ b/conda/vs2019/activate.bat @@ -13,6 +13,10 @@ set "MSYS2_ENV_CONV_EXCL=CL" :: http://stevedower.id.au/blog/building-for-python-3-5-part-two/ for more info set "PY_VCRUNTIME_REDIST=%PREFIX%\\bin\\vcruntime140.dll" +if NOT "%VSINSTALLDIR%" == "" if exist "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" ( + goto :vswhere +) + for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [16^,17^) -property installationPath`) do ( if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( set "VSINSTALLDIR=%%i\" diff --git a/windows/internal/check_deps.bat b/windows/internal/check_deps.bat index 3bda6dadb..f2bf18dc9 100755 --- a/windows/internal/check_deps.bat +++ b/windows/internal/check_deps.bat @@ -30,6 +30,12 @@ IF "%VC_YEAR%" == "2017" ( set VC_VERSION_UPPER=16 ) +if NOT "%VSINSTALLDIR%" == "" if exist "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" ( + set "VS15INSTALLDIR=%VSINSTALLDIR%" + set "VS15VCVARSALL=%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" + goto vswhere +) + for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [%VC_VERSION_LOWER%^,%VC_VERSION_UPPER%^) -property installationPath`) do ( if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( set "VS15INSTALLDIR=%%i" diff --git a/windows/internal/vc_install_helper.bat b/windows/internal/vc_install_helper.bat index f44642f56..e9c2e5040 100644 --- a/windows/internal/vc_install_helper.bat +++ b/windows/internal/vc_install_helper.bat @@ -5,8 +5,28 @@ if "%VC_YEAR%" == "2017" if "%CUDA_VERSION%" == "92" ( set VC_VERSION=14.11 ) ) +if "%VC_YEAR%" == "2019" set VC_VERSION=14.28.29333 if not "%VC_VERSION%" == "" ( set VSDEVCMD_ARGS=-vcvars_ver=%VC_VERSION% ) if "%VC_YEAR%" == "2017" powershell windows/internal/vs2017_install.ps1 %VC_VERSION% +if "%VC_YEAR%" == "2019" powershell windows/internal/vs2019_install.ps1 %VC_VERSION% + +set VC_VERSION_LOWER=16 +set VC_VERSION_UPPER=17 +IF "%VC_YEAR%" == "2017" ( + set VC_VERSION_LOWER=15 + set VC_VERSION_UPPER=16 +) + +for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version [%VC_VERSION_LOWER%^,%VC_VERSION_UPPER%^) -property installationPath`) do ( + if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( + set "VSINSTALLDIR=%%i" + goto vswhere + ) +) + +:vswhere +echo "Setting VSINSTALLDIR to %VSINSTALLDIR%" + if errorlevel 1 exit /b 1 diff --git a/windows/internal/vs2019_install.ps1 b/windows/internal/vs2019_install.ps1 index e436051f0..6f1a40179 100644 --- a/windows/internal/vs2019_install.ps1 +++ b/windows/internal/vs2019_install.ps1 @@ -1,21 +1,52 @@ -$VS_DOWNLOAD_LINK = "https://aka.ms/vs/16/release/vs_buildtools.exe" +# https://developercommunity.visualstudio.com/t/install-specific-version-of-vs-component/1142479 +# https://docs.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers + +# 16.8.5 BuildTools +$VS_DOWNLOAD_LINK = "https://download.visualstudio.microsoft.com/download/pr/20130c62-1bc8-43d6-b4f0-c20bb7c79113/145a319d79a83376915d8f855605e152ef5f6fa2b2f1d2dca411fb03722eea72/vs_BuildTools.exe" +$COLLECT_DOWNLOAD_LINK = "https://aka.ms/vscollect.exe" $VS_INSTALL_ARGS = @("--nocache","--quiet","--wait", "--add Microsoft.VisualStudio.Workload.VCTools", "--add Microsoft.Component.MSBuild", "--add Microsoft.VisualStudio.Component.Roslyn.Compiler", - "--add Microsoft.VisualStudio.Component.VC.CoreBuildTools", + "--add Microsoft.VisualStudio.Component.TextTemplating", + "--add Microsoft.VisualStudio.Component.VC.CoreIde", "--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest", - "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64") + "--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core", + "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81") curl.exe --retry 3 -kL $VS_DOWNLOAD_LINK --output vs_installer.exe if ($LASTEXITCODE -ne 0) { - echo "Download of the VS 2019 installer failed" + echo "Download of the VS 2019 Version 16.8.5 installer failed" exit 1 } +if (Test-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe") { + $existingPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -products "Microsoft.VisualStudio.Product.BuildTools" -version "[16, 17)" -property installationPath + if ($existingPath -ne $null) { + echo "Found existing BuildTools installation in $existingPath" + $VS_UNINSTALL_ARGS = @("uninstall", "--installPath", "`"$existingPath`"", "--quiet","--wait") + $process = Start-Process "${PWD}\vs_installer.exe" -ArgumentList $VS_UNINSTALL_ARGS -NoNewWindow -Wait -PassThru + $exitCode = $process.ExitCode + if (($exitCode -ne 0) -and ($exitCode -ne 3010)) { + echo "Original BuildTools uninstall failed with code $exitCode" + exit 1 + } + echo "Original BuildTools uninstalled" + } +} + $process = Start-Process "${PWD}\vs_installer.exe" -ArgumentList $VS_INSTALL_ARGS -NoNewWindow -Wait -PassThru Remove-Item -Path vs_installer.exe -Force $exitCode = $process.ExitCode if (($exitCode -ne 0) -and ($exitCode -ne 3010)) { - echo "VS 2019 installer exited with code $exitCode, which should be one of [0, 3010]." + echo "VS 2017 installer exited with code $exitCode, which should be one of [0, 3010]." + curl.exe --retry 3 -kL $COLLECT_DOWNLOAD_LINK --output Collect.exe + if ($LASTEXITCODE -ne 0) { + echo "Download of the VS Collect tool failed." + exit 1 + } + Start-Process "${PWD}\Collect.exe" -NoNewWindow -Wait -PassThru + New-Item -Path "C:\w\build-results" -ItemType "directory" -Force + Copy-Item -Path "C:\Users\circleci\AppData\Local\Temp\vslogs.zip" -Destination "C:\w\build-results\" exit 1 } From b91e08277d5a5fdddcd7c35f6b6f6225f6d17186 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 27 Mar 2021 01:43:10 +0800 Subject: [PATCH 2/3] Fix VSINSTALLDIR --- conda/vs2019/activate.bat | 3 ++- windows/internal/check_deps.bat | 5 ++--- windows/internal/vc_install_helper.bat | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conda/vs2019/activate.bat b/conda/vs2019/activate.bat index 5fa75ce93..1967db270 100644 --- a/conda/vs2019/activate.bat +++ b/conda/vs2019/activate.bat @@ -13,7 +13,8 @@ set "MSYS2_ENV_CONV_EXCL=CL" :: http://stevedower.id.au/blog/building-for-python-3-5-part-two/ for more info set "PY_VCRUNTIME_REDIST=%PREFIX%\\bin\\vcruntime140.dll" -if NOT "%VSINSTALLDIR%" == "" if exist "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" ( +if NOT "%VS15INSTALLDIR%" == "" if exist "%VS15INSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" ( + set "VSINSTALLDIR=%VS15INSTALLDIR%\" goto :vswhere ) diff --git a/windows/internal/check_deps.bat b/windows/internal/check_deps.bat index f2bf18dc9..4f29bbeb5 100755 --- a/windows/internal/check_deps.bat +++ b/windows/internal/check_deps.bat @@ -30,9 +30,8 @@ IF "%VC_YEAR%" == "2017" ( set VC_VERSION_UPPER=16 ) -if NOT "%VSINSTALLDIR%" == "" if exist "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" ( - set "VS15INSTALLDIR=%VSINSTALLDIR%" - set "VS15VCVARSALL=%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" +if NOT "%VS15INSTALLDIR%" == "" if exist "%VS15INSTALLDIR%VC\Auxiliary\Build\vcvarsall.bat" ( + set "VS15VCVARSALL=%VS15INSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" goto vswhere ) diff --git a/windows/internal/vc_install_helper.bat b/windows/internal/vc_install_helper.bat index e9c2e5040..2ab0b78a4 100644 --- a/windows/internal/vc_install_helper.bat +++ b/windows/internal/vc_install_helper.bat @@ -21,12 +21,12 @@ IF "%VC_YEAR%" == "2017" ( for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools -version [%VC_VERSION_LOWER%^,%VC_VERSION_UPPER%^) -property installationPath`) do ( if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( - set "VSINSTALLDIR=%%i" + set "VS15INSTALLDIR=%%i" goto vswhere ) ) :vswhere -echo "Setting VSINSTALLDIR to %VSINSTALLDIR%" +echo "Setting VSINSTALLDIR to %VS15INSTALLDIR%" if errorlevel 1 exit /b 1 From cd64f7bf0acd7019f3c1ef85240615049479b42c Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 27 Mar 2021 01:57:20 +0800 Subject: [PATCH 3/3] Minor fix --- windows/internal/check_deps.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/internal/check_deps.bat b/windows/internal/check_deps.bat index 4f29bbeb5..25c4c4a51 100755 --- a/windows/internal/check_deps.bat +++ b/windows/internal/check_deps.bat @@ -30,7 +30,7 @@ IF "%VC_YEAR%" == "2017" ( set VC_VERSION_UPPER=16 ) -if NOT "%VS15INSTALLDIR%" == "" if exist "%VS15INSTALLDIR%VC\Auxiliary\Build\vcvarsall.bat" ( +if NOT "%VS15INSTALLDIR%" == "" if exist "%VS15INSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" ( set "VS15VCVARSALL=%VS15INSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" goto vswhere )