Skip to content

Commit edcd9d6

Browse files
committed
Remove -Daily from install-powershell.ps1 since it no longer exists
Also install the Preview to `~/.powershell-preview` like the daily was.
1 parent c0b50de commit edcd9d6

File tree

2 files changed

+79
-153
lines changed

2 files changed

+79
-153
lines changed

tools/install-powershell.ps1

Lines changed: 70 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,39 @@
55
Install PowerShell on Windows, Linux or macOS.
66
.DESCRIPTION
77
By default, the latest PowerShell release package will be installed.
8-
If '-Daily' is specified, then the latest PowerShell daily package will be installed.
8+
If '-Preview' is specified, then the latest PowerShell preview package will be installed.
99
.Parameter Destination
1010
The destination path to install PowerShell to.
11-
.Parameter Daily
12-
Install PowerShell from the daily build.
13-
Note that the 'PackageManagement' module is required to install a daily package.
11+
.Parameter Preview
12+
Install the latest PowerShell preview build.
1413
.Parameter DoNotOverwrite
1514
Do not overwrite the destination folder if it already exists.
1615
.Parameter AddToPath
1716
On Windows, add the absolute destination path to the 'User' scope environment variable 'Path';
1817
On Linux, make the symlink '/usr/bin/pwsh' points to "$Destination/pwsh";
1918
On MacOS, make the symlink '/usr/local/bin/pwsh' points to "$Destination/pwsh".
2019
.EXAMPLE
21-
Install the daily build
22-
.\install-powershell.ps1 -Daily
20+
Install the preview build
21+
.\install-powershell.ps1 -Preview
2322
.EXAMPLE
2423
Invoke this script directly from GitHub
25-
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -daily"
24+
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -Preview"
2625
#>
27-
[CmdletBinding(DefaultParameterSetName = "Daily")]
26+
[CmdletBinding()]
2827
param(
29-
[Parameter(ParameterSetName = "Daily")]
30-
[string] $Destination,
28+
[Parameter()]
29+
[switch] $Preview,
30+
31+
[Parameter()]
32+
[switch] $Daily, # Exists for backward compatibility
3133

32-
[Parameter(ParameterSetName = "Daily")]
33-
[switch] $Daily,
34+
[Parameter()]
35+
[string] $Destination,
3436

35-
[Parameter(ParameterSetName = "Daily")]
37+
[Parameter()]
3638
[switch] $DoNotOverwrite,
3739

38-
[Parameter(ParameterSetName = "Daily")]
40+
[Parameter()]
3941
[switch] $AddToPath,
4042

4143
[Parameter(ParameterSetName = "MSI")]
@@ -48,10 +50,7 @@ param(
4850
[switch] $AddExplorerContextMenu,
4951

5052
[Parameter(ParameterSetName = "MSI")]
51-
[switch] $EnablePSRemoting,
52-
53-
[Parameter()]
54-
[switch] $Preview
53+
[switch] $EnablePSRemoting
5554
)
5655

5756
Set-StrictMode -Version 3.0
@@ -61,15 +60,20 @@ $IsLinuxEnv = (Get-Variable -Name "IsLinux" -ErrorAction Ignore) -and $IsLinux
6160
$IsMacOSEnv = (Get-Variable -Name "IsMacOS" -ErrorAction Ignore) -and $IsMacOS
6261
$IsWinEnv = !$IsLinuxEnv -and !$IsMacOSEnv
6362

63+
if ($Daily) {
64+
$Preview = $true
65+
Write-Warning "The '-Daily' build is deprecated. Continuing as if '-Preview' was specified instead."
66+
}
67+
6468
if (-not $Destination) {
6569
if ($IsWinEnv) {
6670
$Destination = "$env:LOCALAPPDATA\Microsoft\powershell"
6771
} else {
6872
$Destination = "~/.powershell"
6973
}
7074

71-
if ($Daily) {
72-
$Destination = "${Destination}-daily"
75+
if ($Preview) {
76+
$Destination = "${Destination}-preview"
7377
}
7478
}
7579

@@ -265,145 +269,68 @@ try {
265269
$originalValue = [Net.ServicePointManager]::SecurityProtocol
266270
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
267271

268-
if ($Daily) {
269-
$metadata = Invoke-RestMethod 'https://aka.ms/pwsh-buildinfo-daily'
272+
$metadata = Invoke-RestMethod 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json'
273+
if ($Preview) {
274+
$release = $metadata.PreviewReleaseTag -replace '^v'
275+
} else {
270276
$release = $metadata.ReleaseTag -replace '^v'
277+
}
271278

272-
# Get version from currently installed PowerShell Daily if available.
273-
$pwshPath = if ($IsWinEnv) {Join-Path $Destination "pwsh.exe"} else {Join-Path $Destination "pwsh"}
274-
$currentlyInstalledVersion = if(Test-Path $pwshPath) {
275-
((& $pwshPath -version) -split " ")[1]
276-
}
277-
278-
if($currentlyInstalledVersion -eq $release) {
279-
Write-Verbose "Latest PowerShell Daily already installed." -Verbose
280-
return
281-
}
282-
283-
if ($IsWinEnv) {
284-
if ($UseMSI) {
285-
$packageName = "PowerShell-${release}-win-${architecture}.msi"
286-
} else {
287-
$packageName = "PowerShell-${release}-win-${architecture}.zip"
288-
}
289-
} elseif ($IsLinuxEnv) {
290-
$packageName = "powershell-${release}-linux-${architecture}.tar.gz"
291-
} elseif ($IsMacOSEnv) {
292-
$packageName = "powershell-${release}-osx-${architecture}.tar.gz"
279+
if ($IsWinEnv) {
280+
if ($UseMSI) {
281+
$packageName = "PowerShell-${release}-win-${architecture}.msi"
282+
} else {
283+
$packageName = "PowerShell-${release}-win-${architecture}.zip"
293284
}
285+
} elseif ($IsLinuxEnv) {
286+
$packageName = "powershell-${release}-linux-${architecture}.tar.gz"
287+
} elseif ($IsMacOSEnv) {
288+
$packageName = "powershell-${release}-osx-${architecture}.tar.gz"
289+
}
294290

295-
if ($architecture -ne "x64") {
296-
throw "The OS architecture is '$architecture'. However, we currently only support daily package for x64."
297-
}
291+
$downloadURL = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/${packageName}"
292+
Write-Verbose "About to download package from '$downloadURL'" -Verbose
298293

299-
$downloadURL = "https://powershellinfraartifacts-gkhedzdeaghdezhr.z01.azurefd.net/install/$($metadata.ReleaseTag)/$packageName"
300-
Write-Verbose "About to download package from '$downloadURL'" -Verbose
294+
$packagePath = Join-Path -Path $tempDir -ChildPath $packageName
295+
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
296+
# On Windows PowerShell, progress can make the download significantly slower
297+
$oldProgressPreference = $ProgressPreference
298+
$ProgressPreference = "SilentlyContinue"
299+
}
301300

302-
$packagePath = Join-Path -Path $tempDir -ChildPath $packageName
301+
try {
302+
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
303+
} finally {
303304
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
304-
# On Windows PowerShell, progress can make the download significantly slower
305-
$oldProgressPreference = $ProgressPreference
306-
$ProgressPreference = "SilentlyContinue"
305+
$ProgressPreference = $oldProgressPreference
307306
}
307+
}
308308

309-
try {
310-
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
311-
} finally {
312-
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
313-
$ProgressPreference = $oldProgressPreference
314-
}
315-
}
316-
317-
$contentPath = Join-Path -Path $tempDir -ChildPath "new"
318-
319-
$null = New-Item -ItemType Directory -Path $contentPath -ErrorAction SilentlyContinue
320-
if ($IsWinEnv) {
321-
if ($UseMSI -and $Quiet) {
322-
Write-Verbose "Performing quiet install"
323-
$ArgumentList=@("/i", $packagePath, "/quiet")
324-
if($MSIArguments) {
325-
$ArgumentList+=$MSIArguments
326-
}
327-
$process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru
328-
if ($process.exitcode -ne 0) {
329-
throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights"
330-
}
331-
} elseif ($UseMSI) {
332-
if($MSIArguments) {
333-
Start-Process $packagePath -ArgumentList $MSIArguments -Wait
334-
} else {
335-
Start-Process $packagePath -Wait
336-
}
337-
} else {
338-
Expand-ArchiveInternal -Path $packagePath -DestinationPath $contentPath
339-
}
340-
} else {
341-
tar zxf $packagePath -C $contentPath
342-
}
343-
} else {
344-
$metadata = Invoke-RestMethod https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json
345-
if ($Preview) {
346-
$release = $metadata.PreviewReleaseTag -replace '^v'
347-
} else {
348-
$release = $metadata.ReleaseTag -replace '^v'
349-
}
309+
$contentPath = Join-Path -Path $tempDir -ChildPath "new"
350310

351-
if ($IsWinEnv) {
352-
if ($UseMSI) {
353-
$packageName = "PowerShell-${release}-win-${architecture}.msi"
354-
} else {
355-
$packageName = "PowerShell-${release}-win-${architecture}.zip"
311+
$null = New-Item -ItemType Directory -Path $contentPath -ErrorAction SilentlyContinue
312+
if ($IsWinEnv) {
313+
if ($UseMSI -and $Quiet) {
314+
Write-Verbose "Performing quiet install"
315+
$ArgumentList=@("/i", $packagePath, "/quiet")
316+
if($MSIArguments) {
317+
$ArgumentList+=$MSIArguments
356318
}
357-
} elseif ($IsLinuxEnv) {
358-
$packageName = "powershell-${release}-linux-${architecture}.tar.gz"
359-
} elseif ($IsMacOSEnv) {
360-
$packageName = "powershell-${release}-osx-${architecture}.tar.gz"
361-
}
362-
363-
$downloadURL = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/${packageName}"
364-
Write-Verbose "About to download package from '$downloadURL'" -Verbose
365-
366-
$packagePath = Join-Path -Path $tempDir -ChildPath $packageName
367-
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
368-
# On Windows PowerShell, progress can make the download significantly slower
369-
$oldProgressPreference = $ProgressPreference
370-
$ProgressPreference = "SilentlyContinue"
371-
}
372-
373-
try {
374-
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
375-
} finally {
376-
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
377-
$ProgressPreference = $oldProgressPreference
319+
$process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru
320+
if ($process.exitcode -ne 0) {
321+
throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights"
378322
}
379-
}
380-
381-
$contentPath = Join-Path -Path $tempDir -ChildPath "new"
382-
383-
$null = New-Item -ItemType Directory -Path $contentPath -ErrorAction SilentlyContinue
384-
if ($IsWinEnv) {
385-
if ($UseMSI -and $Quiet) {
386-
Write-Verbose "Performing quiet install"
387-
$ArgumentList=@("/i", $packagePath, "/quiet")
388-
if($MSIArguments) {
389-
$ArgumentList+=$MSIArguments
390-
}
391-
$process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru
392-
if ($process.exitcode -ne 0) {
393-
throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights"
394-
}
395-
} elseif ($UseMSI) {
396-
if($MSIArguments) {
397-
Start-Process $packagePath -ArgumentList $MSIArguments -Wait
398-
} else {
399-
Start-Process $packagePath -Wait
400-
}
323+
} elseif ($UseMSI) {
324+
if($MSIArguments) {
325+
Start-Process $packagePath -ArgumentList $MSIArguments -Wait
401326
} else {
402-
Expand-ArchiveInternal -Path $packagePath -DestinationPath $contentPath
327+
Start-Process $packagePath -Wait
403328
}
404329
} else {
405-
tar zxf $packagePath -C $contentPath
330+
Expand-ArchiveInternal -Path $packagePath -DestinationPath $contentPath
406331
}
332+
} else {
333+
tar zxf $packagePath -C $contentPath
407334
}
408335

409336
if (-not $UseMSI) {

tools/install-powershell.ps1-README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22

33
## Features of install-powershell.ps1
44

5-
* Can be called directly from git
6-
* Optionally allows install of the latest Preview build
7-
* Optionally allows install of the Daily build
8-
* Optionally installs using the latest MSI
9-
* Automatically looks up latest version via git tags
10-
* Optionally installs silently
11-
* Optionally adds the install location to Path environment variable
5+
- Can be called directly from Git
6+
- Optionally allows install of the latest Preview build
7+
- Optionally installs using the latest MSI
8+
- Automatically looks up latest version via Git tags
9+
- Optionally installs silently
10+
- Optionally adds the install location to Path environment variable
1211

1312
## Examples
1413

15-
### Install PowerShell Core Daily Build
14+
### Install PowerShell Preview Build
1615

1716
```PowerShell
18-
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -daily"
17+
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -Preview"
1918
```
2019

21-
### Install PowerShell Core using the MSI installer
20+
### Install PowerShell using the MSI installer
2221

2322
```PowerShell
2423
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -UseMSI"

0 commit comments

Comments
 (0)