php-sqlsrv/test/Performance/setup_env_windows.ps1
v-susanh 22a5034c7d updated scripts to take pre-compiled driver binaries (#504)
* updated scripts to take pre-compiled driver binaries
2017-08-21 15:46:39 -07:00

71 lines
2.6 KiB
PowerShell

Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$PHP_ZIP,
[Parameter(Mandatory=$True,Position=2)]
[string]$SQLSRV_DRIVER,
[Parameter(Mandatory=$True,Position=3)]
[string]$PDO_DRIVER
)
$ErrorActionPreference = "Stop"
$startingDir=$pwd.Path
$tempFolder=Join-Path $startingDir "temp"
Remove-Item temp -Recurse -Force -ErrorAction Ignore
New-Item -ItemType directory -Path temp
Write-Host "Installing chocolatey..."
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Write-Host "Installing Git..."
choco install -y git
$gitDir = 'C:\Program Files\Git\cmd\git.exe'
Write-Host "Installing Python3..."
choco install -y python3
RefreshEnv
Write-Host "Installing pyodbc..."
C:\Python*\Scripts\pip3.exe install pyodbc | Out-Null
Write-Host "Downloading MSODBCSQL..."
#This needs to be manually updated when there is a new release
(New-object System.Net.WebClient).DownloadFile('https://download.microsoft.com/download/D/5/E/D5EEF288-A277-45C8-855B-8E2CB7E25B96/x64/msodbcsql.msi', "$tempFolder\msodbcsql.msi")
Write-Host "Installing MSODBCSQL..."
msiexec /quiet /passive /qn /i $tempFolder\msodbcsql.msi IACCEPTMSODBCSQLLICENSETERMS=YES | Out-Null
Write-Host "Installing 7-Zip..."
choco install -y 7zip.install
Write-Host "Installing PHP..."
$phpDir="C:\php"
# remove existing PHP and setup new one
Remove-Item $phpDir -Recurse -ErrorAction Ignore
New-Item -ItemType directory -Path $phpDir
Expand-Archive $PHP_ZIP -DestinationPath $phpDir
Copy-Item $SQLSRV_DRIVER $phpDir\ext
Copy-Item $PDO_DRIVER $phpDir\ext
# setup driver
Copy-Item $phpDir\php.ini-production $phpDir\php.ini
Add-Content $phpDir\php.ini "extension=$phpDir\ext\php_openssl.dll"
Add-Content $phpDir\php.ini "extension=$phpDir\ext\php_mbstring.dll"
$driverName=Split-Path $SQLSRV_DRIVER -leaf
Add-Content $phpDir\php.ini "extension=$phpDir\ext\$driverName"
$driverName=Split-Path $PDO_DRIVER -leaf
Add-Content $phpDir\php.ini "extension=$phpDir\ext\$driverName"
Move-Item $phpDir\php.ini C:\Windows -force
Copy-Item $phpDir\ssleay32.dll C:\Windows -force
Copy-Item $phpDir\libeay32.dll C:\Windows -force
cd $startingDir
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";" + $phpDir + ";" + $gitDir, [System.EnvironmentVariableTarget]::Machine)
$env:Path = $env:Path + ";" + $phpDir + ";" + $gitDir
RefreshEnv
# setup composer
wget https://getcomposer.org/installer -O composer-setup.php
php composer-setup.php
php composer.phar install
Remove-Item temp -Recurse -Force -ErrorAction Ignore
Write-Host "Setup completed!"