@@ -22,50 +22,65 @@ jobs:
2222
2323 - pwsh : |
2424 Write-Output ${{ parameters.vmImageName }}
25- $url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/PowerShell-7.3.0-preview.6-win-x64.zip"
26- $isTar = $false
25+
26+ if ("${{ parameters.vmImageName }}" -like 'windows-*')
27+ {
28+ $url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/PowerShell-7.3.0-preview.6-win-x64.zip"
29+ $downloadFilename = "pwsh_download.msi"
30+ }
31+
2732 if ("${{ parameters.vmImageName }}" -like 'macos-*')
2833 {
29- $url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/powershell-7.3.0-preview.6-osx-x64.tar.gz"
30- $isTar = $true
31- Write-Output "Choose macOS"
34+ $url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/powershell-7.3.0-preview.6-osx-x64.pkg"
35+ $downloadFilename = "pwsh_download.pkg"
3236 }
3337 if ("${{ parameters.vmImageName }}" -like 'ubuntu-*')
3438 {
3539 $url = "https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/powershell-7.3.0-preview.6-linux-x64.tar.gz"
36- $isTar = $true
37- Write-Output "Choose Ubuntu"
40+ $downloadFilename = "pwsh_download.tar.gz"
3841 }
39- $destination = "powershell-preview-archive"
40- if ($isTar) {
41- $destination += ".tar.gz"
42- } else {
43- $destination += ".zip"
42+
43+ $downloadDestination = Join-Path $pwd $downloadFilename
44+ Invoke-WebRequest -Uri $url -OutFile $downloadDestination
45+
46+ # Installation steps for windows
47+ if ("${{ parameters.vmImageName }}" -like 'windows-*') {
48+ Expand-Archive -Path $downloadDestination -DestinationPath "pwsh-preview"
49+ $powerShellPreview = Join-Path $pwd "pwsh-preview" "pwsh.exe"
4450 }
45- Invoke-WebRequest -Uri $url -OutFile $destination
46- ## unpack the downloaded file
47- $powershellPreview = Join-Path $pwd "powershell-preview"
48- mkdir $powershellPreview
49- if ($isTar)
51+ if ("${{ parameters.vmImageName }}" -like 'ubuntu-*')
5052 {
51- gunzip -d $destination
52- $destination = $destination .Replace(".gz", "")
53- tar -x -f $destination -C $powershellPreview
54- } else {
55- Expand-Archive -Path $destination -DestinationPath $powershellPreview
53+ gunzip -d $downloadDestination
54+ $downloadDestination = $downloadDestination .Replace(".gz", "")
55+ mkdir "pwsh-preview"
56+ tar -x -f $downloadDestination -C "pwsh-preview"
57+ $powerShellPreview = Join -Path $pwd "pwsh-preview" "pwsh"
5658 }
57- # Print contents of $powershellPreview
58- #Get-ChildItem $powershellPreview | Format-Table "Name"
59- $powershellPreview = Join-Path $powershellPreview "pwsh"
60- if ("${{ parameters.vmImageName }}" -like 'windows-*')
59+ if ("${{ parameters.vmImageName }}" -like 'macos-*')
6160 {
62- $powerShellPreview += ".exe"
61+ sudo xattr -rd com.apple.quarantine "${downloadDestination}"
62+ sudo installer -pkg "${downloadDestination}" -target /
63+ $powerShellPreview = "pwsh-preview"
6364 }
6465 # Write the location of PowerShell Preview
6566 Write-Host "##vso[task.setvariable variable=PowerShellPreviewExecutablePath;]$powershellPreview"
6667 displayName: Download and Install PowerShell Preview
6768
6869 - pwsh : |
70+ $destination = Join-Path $pwd "7z.exe"
71+ $installUrl = "https://www.7-zip.org/a/7z2201-x64.exe"
72+ Invoke-WebRequest -Uri $installUrl -OutFile $destination
73+ # Run the installer in silent mode
74+ .$destination /S /D="C:\Program Files\7-Zip"
75+ displayName: Install 7-zip
76+ condition: and(succeeded(), startswith('${{ parameters.vmImageName }}', 'windows'))
77+
78+ - pwsh : |
79+ if ("${{ parameters.vmImageName }}" -like 'windows-*')
80+ {
81+ # Add 7-zip to PATH on Windows
82+ [System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+';C:\Program Files\7-zip')
83+ }
6984 "$(PowerShellPreviewExecutablePath) .azdevops/RunTests.ps1" | Invoke-Expression
7085 displayName: Run Tests
7186
0 commit comments