@@ -22,50 +22,65 @@ jobs:
22
22
23
23
- pwsh : |
24
24
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
+
27
32
if ("${{ parameters.vmImageName }}" -like 'macos-*')
28
33
{
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"
32
36
}
33
37
if ("${{ parameters.vmImageName }}" -like 'ubuntu-*')
34
38
{
35
39
$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"
38
41
}
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"
44
50
}
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-*')
50
52
{
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"
56
58
}
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-*')
61
60
{
62
- $powerShellPreview += ".exe"
61
+ sudo xattr -rd com.apple.quarantine "${downloadDestination}"
62
+ sudo installer -pkg "${downloadDestination}" -target /
63
+ $powerShellPreview = "pwsh-preview"
63
64
}
64
65
# Write the location of PowerShell Preview
65
66
Write-Host "##vso[task.setvariable variable=PowerShellPreviewExecutablePath;]$powershellPreview"
66
67
displayName: Download and Install PowerShell Preview
67
68
68
69
- 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
+ }
69
84
"$(PowerShellPreviewExecutablePath) .azdevops/RunTests.ps1" | Invoke-Expression
70
85
displayName: Run Tests
71
86
0 commit comments