mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
* First iteration * Second iteration * Third iteration * Fourth iteration * Fifth iteration * Revert the temporary workaround * beta.1 release only support Mac OSX 10.12+
46 lines
2.4 KiB
Docker
46 lines
2.4 KiB
Docker
# escape=`
|
|
FROM microsoft/windowsservercore:latest
|
|
|
|
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>"
|
|
LABEL readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md"
|
|
LABEL description="This Dockerfile will install the latest release of PS."
|
|
|
|
ARG POWERSHELL_MSI=https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-beta.1/PowerShell-6.0.0-beta.1-win10-win2016-x64.msi
|
|
|
|
# Setup PowerShell - Log-to > C:\Docker.log
|
|
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
|
|
ADD $POWERSHELL_MSI /PowerShell-win10-x64.msi
|
|
|
|
# Install PowerShell package and clean up
|
|
RUN $ErrorActionPreference='Stop'; `
|
|
$ConfirmPreference='None'; `
|
|
$VerbosePreference='Continue'; `
|
|
Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; `
|
|
$PSVersionTable | Write-Output ; `
|
|
$VerInfo = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' ; `
|
|
('FullBuildString: '+$VerInfo.BuildLabEx) | Write-Output ; `
|
|
('OperatingSystem: '+$VerInfo.ProductName+' '+$VerInfo.EditionId+' '+$VerInfo.InstallationType) | Write-Output ; `
|
|
[System.IO.FileInfo]$MsiFile = Get-Item -Path ./PowerShell-win10-x64.msi ; `
|
|
Start-Process -FilePath msiexec.exe -ArgumentList '-qn','-i c:\PowerShell-win10-x64.msi', `
|
|
'-log c:\PowerShell-win10-x64.msi.log','-norestart' -wait ; `
|
|
$log=get-content -Path C:\PowerShell-win10-x64.msi.log -Last 10 ; `
|
|
if ($log -match 'Installation success or error status: 0') { `
|
|
Remove-Item -Path $MsiFile ; `
|
|
$psexe=Get-Item -Path $Env:ProgramFiles\PowerShell\*\powershell.exe ; `
|
|
New-Item -Type SymbolicLink -Path $Env:ProgramFiles\PowerShell\ -Name latest -Value $psexe.DirectoryName `
|
|
} else { throw 'Installation failed! See c:\PowerShell-win10-x64.msi.log' } ;
|
|
|
|
# Verify New Powershell.exe runs
|
|
SHELL ["C:\\Program Files\\PowerShell\\latest\\PowerShell.exe", "-command"]
|
|
RUN Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; `
|
|
$ErrorActionPreference='Stop'; `
|
|
Write-Output $PSVersionTable ; `
|
|
If (-not($PSVersionTable.PSEdition -Match 'Core')) { `
|
|
Throw [String]$('['+$PSVersionTable.PSEdition+'] is not [Core]!') ; `
|
|
} ;
|
|
|
|
# Persist %PSCORE% ENV variable for user convenience
|
|
ENV PSCORE='"C:\Program Files\PowerShell\latest\PowerShell.exe"'
|
|
|
|
ENTRYPOINT ["C:\\Program Files\\PowerShell\\latest\\PowerShell.exe"]
|