Skip to content

Commit

Permalink
fix(install): add vs redistributable installation in powershell script (
Browse files Browse the repository at this point in the history
#490)

* VS C++ redist installation

* add VS C++ redist installtion

---------

Co-authored-by: Krish Patel <[email protected]>
Co-authored-by: Richard Abrich <[email protected]>
  • Loading branch information
3 people authored Nov 11, 2023
1 parent 396bbb5 commit 086a5ca
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions install/install_openadapt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ $gitCmd = "git"
$gitInstaller = "Git-2.40.1-64-bit.exe"
$gitInstallerLoc = "https://github.com/git-for-windows/git/releases/download/v2.40.1.windows.1/Git-2.40.1-64-bit.exe"
$gitUninstaller = "C:\Program Files\Git\unins000.exe"

$VCRedistInstaller = "vc_redist.x64.exe"
$VCRedistInstallerLoc = "https://aka.ms/vs/17/release/vc_redist.x64.exe"
$VCRedistRegPath = "HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64"
################################ PARAMETERS ################################


Expand Down Expand Up @@ -255,10 +259,42 @@ function GetGitCMD {
# Return the git command
return $gitCmd
}


function Install-VCRedist {
# Check if Visual C++ Redist is installed
try {
$vcredistExists = (Get-ItemPropertyValue -Path $VCRedistRegPath -Name Installed -ErrorAction Stop)
}
catch {
$vcredistExists = $false
}

if (!$vcredistExists) {
# Install Visual C++ Redist
Write-Host "Downloading Visual C++ Redist"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $VCRedistInstallerLoc -OutFile $VCRedistInstaller

if (-Not (Test-Path -Path $VCRedistInstaller -PathType Leaf)) {
Write-Host "Failed to download Visual C++ installer"
return
}

Write-Host "Installing Visual C++ Redist, click 'Yes' if prompted for permission"
Start-Process -FilePath $VCRedistInstaller -Verb runAs -ArgumentList "/install /quiet /norestart" -Wait
Remove-Item $VCRedistInstaller

if ($LastExitCode) {
Write-Host "Failed to install Visual C++ Redist: $LastExitCode"
return
}
}
}
################################ FUNCTIONS ################################


################################ SCRIPT ################################
################################ SCRIPT ###################################

Write-Host "Install Script Started..." -ForegroundColor Yellow

Expand All @@ -277,6 +313,8 @@ RunAndCheck "$python --version" "check Python"
$git = GetGitCMD
RunAndCheck "$git --version" "check Git"

Install-VCRedist

# OpenAdapt Setup
RunAndCheck "git clone -q https://github.com/MLDSAI/OpenAdapt.git" "clone git repo"
Set-Location .\OpenAdapt
Expand All @@ -287,4 +325,4 @@ RunAndCheck "poetry run pytest" "Run ``Pytest``" -SkipCleanup:$true
Write-Host "OpenAdapt installed Successfully!" -ForegroundColor Green
Start-Process powershell -Verb RunAs -ArgumentList "-NoExit", "-Command", "Set-Location -Path '$pwd'; poetry shell"

################################ SCRIPT ################################
################################ SCRIPT ###################################

0 comments on commit 086a5ca

Please sign in to comment.