diff --git a/docker/nightly/windowsservercore/Dockerfile b/docker/nightly/windowsservercore/Dockerfile new file mode 100644 index 00000000000..09a78813383 --- /dev/null +++ b/docker/nightly/windowsservercore/Dockerfile @@ -0,0 +1,83 @@ +# escape=` +FROM brycem/win10build +LABEL Readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md",` + Description="This Dockerfile will install and build the latest nighly PS build." + +ARG FORK=PowerShell +ARG BRANCH=master +ARG PULLREQ=na + +# Prepare shell environment to Log-to > C:\Dockerfile.log +SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","-command","$ErrorActionPreference = 'Stop';","$ConfirmPreference = 'None';",` + "$VerbosePreference = 'Continue';","Start-Transcript -path C:\\Dockerfile.log -append -IncludeInvocationHeader;","$PSVersionTable|Write-Output;",` + "$WinVer = $(Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion');",` + "$OsVer = $('OperatingSystem: '+ $WinVer.ProductName +' '+$WinVer.EditionId+' '+$WinVer.InstallationType);",` + "$BldVer = $('FullBuildString: '+ $WinVer.BuildLabEx); Write-Output -InputObject $OsVer,$BldVer; "] +WORKDIR / + +# Build & Test PowerShell +RUN $vcBld = ${env:ProgramFiles(x86)}+'\Microsoft Visual C++ Build Tools\vcbuildtools.bat';` + test-path $vcBld; [String]$cmdline = ([char]0x0022+$vcBld+[char]0x0022+' x64&set');` + cmd /c $cmdLine | Foreach-Object {$cmdVar,$cmdVal=$_.split('=');Set-Item -Path env:$cmdVar -Value $cmdVal};` + dir env:|out-host;` + If (test-path c:\PowerShell) {Remove-Item c:\PowerShell -Recurse -Force -ea Ignore}` + $gitArgs=@('clone','-v','--recursive',('https://github.com/'+$env:FORK+'/PowerShell.git'),'-b',$env:BRANCH);` + $proc = Start-Process git.exe -ArgumentList $gitArgs -PassThru -Wait -NoNewWindow;` + If (($proc.ExitCode -eq 0) -and (Test-Path 'C:\PowerShell\Build.psm1')) {` + Write-Host 'PowerShell repo successfully cloned to c:\PowerShell.'` + } else {Echo $gitArgs; dir c:\PowerShell\;Throw ('git.exe returned '+$proc.ExitCode)}` + Set-Location C:\PowerShell;` + If ($Env:PULLREQ -ne 'na') {` + $gitArgs=@('fetch','-v','origin',('+refs/pull/'+$env:PULLREQ+'/merge:'));` + $proc = Start-Process git.exe -ArgumentList $gitArgs -PassThru -Wait -NoNewWindow;` + If ($proc.ExitCode -eq 0) {` + Write-Host ('PowerShell repo successfully fetched PR:'+$env:PULLREQ)` + } else {Echo $gitArgs; Throw ('git.exe returned '+$proc.ExitCode)}` + $gitArgs=@('checkout','-vf','FETCH_HEAD')` + }` + $Global:IsWindows=$true;` + git submodule update --init;` + Import-Module .\build.psm1;Start-PSBootstrap;` + Start-PSBuild -Clean -CrossGen -Publish -PSModuleRestore -Configuration 'Release' -Runtime 'win10-x64';` + $testResultsNonAdminFile = 'C:\TestsResultsNonAdmin.xml';` + $testResultsAdminFile = 'C:\TestsResultsAdmin.xml';` + $ExcludeTag = @('Slow', 'Feature', 'Scenario');` + Write-Host -Foreground Green 'Running "CI" CoreCLR tests..';` + $env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Configuration 'Release'));` + Start-PSPester -bindir $env:CoreOutput -outputFile $testResultsNonAdminFile -Unelevate -Tag @() ` + -ExcludeTag ($ExcludeTag + @('RequireAdminOnWindows'));` + Start-PSPester -bindir $env:CoreOutput -outputFile $testResultsAdminFile ` + -Tag @('RequireAdminOnWindows') -ExcludeTag $ExcludeTag;` + Test-PSPesterResults -TestResultsFile $testResultsNonAdminFile,$testResultsAdminFile;` + Start-PSBuild -FullCLR -Configuration 'Release' -PSModuleRestore;` + $env:FullOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -FullCLR));` + Write-Host -Foreground Green 'Run FullCLR tests';` + $testResultsFileFullCLR = 'C:\TestsResults.FullCLR.xml';` + Start-PSPester -FullCLR -bindir $env:FullOutput -outputFile $testResultsFileFullCLR ` + -Tag $null -path 'test/fullCLR';` + Test-PSPesterResults -TestResultsFile $testResultsFileFullCLR;` + Set-BuildVariable -Name TestPassed -Value True;` + $zipFile = Start-PSPackage -Type zip; $msiFile = Start-PSPackage -Type msi;` + $MsiArgs = @(('/i '+$msiFile),'/log c:\PowerShell-win10-x64.msi.log','/qn','/norestart');` + $proc = Start-Process -FilePath msiexec.exe -ArgumentList $MsiArgs -wait -PassThru;` + If ($proc.ExitCode -eq 0) {` + $psexe = Get-Item -Path $Env:ProgramFiles\PowerShell\*\powershell.exe;` + Write-Host ('Successfully installed to '+$psexe);` + New-Item -Type SymbolicLink -Path $Env:ProgramFiles\PowerShell\ -Name Core ` + -Value $psexe.DirectoryName | Out-Null;` + $PSVersionTable | Export-Clixml -Path .\OsPsVer.clix;` + [System.Environment]::SetEnvironmentVariable('PsCoreExe',($psexe.FullName),'Machine')` + } else {` + Write-Output -InputObject $(get-content -Path C:\PowerShell-win10-x64.msi.log -ea Ignore);` + Throw ('Installation failed! PowerShell-win10-x64.msi returned '+$proc.ExitCode)` + } + +# Verify New Powershell.exe +SHELL ["C:\\Program Files\\PowerShell\\Core\\powershell.exe","-command","$ErrorActionPreference='Stop';"] +RUN $PSVersionTable|Out-Host; $OsPsVer = Import-Clixml -Path .\OsPsVer.clix;` + If ($PSVersionTable.PSEdition -ne 'Core') {Throw ('['+$PSVersionTable.PSEdition+'] is not [Core]!')}` + If ($PSVersionTable.PSVersion -eq $OsPsVer.PSVersion) {Throw ('['+$PSVersionTable.PSVersion+'] is unchanged...')}` + Remove-Item C:\Dockerfile.log -Force; Remove-Item C:\PowerShell\OsPsVer.clix -Force;` + Write-Host ('Hello World! PowerShell Core '+$PSVersionTable.PSVersion+' has been built and installed.') + +ENTRYPOINT ["C:\\Program Files\\PowerShell\\Core\\powershell.exe","-noexit","-command","$ErrorActionPreference='Stop';"] \ No newline at end of file diff --git a/docker/release/nanoserver/Dockerfile b/docker/release/nanoserver/Dockerfile index eb68d4f993a..111a2618e37 100644 --- a/docker/release/nanoserver/Dockerfile +++ b/docker/release/nanoserver/Dockerfile @@ -1,48 +1,44 @@ # escape=` FROM microsoft/nanoserver -MAINTAINER brycem@microsoft.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." +LABEL Readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md",` + Description="This Dockerfile will install the latest milestone release of PS." -ARG POWERSHELL_ZIP=https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.14/powershell-6.0.0-alpha.14-win10-x64.zip -ARG POWERSHELL_SHA256=3F5FD873B6E3062D9741B019BC645E6F20999BE66B2FDAA4374495FEBEDD0E03 +ARG POWERSHELL_ZIP=https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.15/PowerShell_6.0.0-alpha.15-win10-win2k16-x64.zip +ARG POWERSHELL_SHA256=4297C4ADBF93133CD343B7A4248FAEE225060E3A739A38D9368E1AA2086381BB -# Setup PowerShell - Log-to > C:\Docker.log -SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"] -ADD $POWERSHELL_ZIP /powershell-win10-x64.zip -ENV POWERSHELL_SHA256=$POWERSHELL_SHA256 +# Prepare shell environment to Log-to > C:\Dockerfile.log +SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","-command","$ErrorActionPreference = 'Stop';","$ConfirmPreference = 'None';",` + "$VerbosePreference = 'Continue';","Start-Transcript -path C:\\Dockerfile.log -append -IncludeInvocationHeader;","$PSVersionTable|Write-Output;",` + "$WinVer = $(Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion');",` + "$OsVer = $('OperatingSystem: '+ $WinVer.ProductName +' '+$WinVer.EditionId+' '+$WinVer.InstallationType);",` + "$BldVer = $('FullBuildString: '+ $WinVer.BuildLabEx); Write-Output -InputObject $OsVer,$BldVer; "] +WORKDIR / # 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]$ZipFile = Get-Item -Path ./powershell-win10-x64.zip ; ` - [String]$ZipHash=(Get-FileHash -Path $ZipFile -Algorithm SHA256 | select -ExpandProperty Hash) ; ` - If ($ZipHash -notmatch $Env:POWERSHELL_SHA256) { ` - Throw [String]$('['+$ZipHash+'] does not match ['+$Env:POWERSHELL_SHA256+']!') ` - } ; ` - New-Item -Path $Env:ProgramFiles/PowerShell -ItemType Directory -Force | out-null ; ` - [System.IO.DirectoryInfo]$PsFolder=New-Item -Path $Env:ProgramFiles\PowerShell -ItemType Directory -Force ; ` - Add-Type -AssemblyName System.IO.Compression.ZipFile ; ` - [System.IO.Compression.ZipFile]::ExtractToDirectory($ZipFile,$PsFolder) ; ` - if (Get-ChildItem -Path $PsFolder/powershell.exe) { ` - Remove-Item -Path $ZipFile ; ` - New-Item -Type SymbolicLink -Path $PsFolder\ -Name Core -Value $PsFolder ` - } else { throw 'Installation failed! See c:\Dockerfile.log' } ; +ADD $POWERSHELL_ZIP /PowerShell-win10-win2k16-x64.zip +RUN [System.IO.FileInfo]$ZipFile = Get-Item -Path ./powershell-win10-win2k16-x64.zip;` + [String]$ZipHash = (Get-FileHash -Path $ZipFile -Algorithm SHA256 | select -ExpandProperty Hash);` + If ($ZipHash -notmatch $Env:POWERSHELL_SHA256){` + Throw [String]$('['+$ZipHash+'] does not match ['+$Env:POWERSHELL_SHA256+']!')` + }` + [System.IO.DirectoryInfo]$PsFolder=New-Item -Path $Env:ProgramFiles\PowerShell -ItemType Directory -Force;` + Add-Type -AssemblyName System.IO.Compression.ZipFile;` + [System.IO.Compression.ZipFile]::ExtractToDirectory($ZipFile,$PsFolder);` + If (Get-ChildItem -Path $PsFolder/powershell.exe){` + Write-Host 'Powershell installation completed successfully.'; Remove-Item -Path $ZipFile;` + New-Item -Type SymbolicLink -Path $PsFolder\ -Name Core -Value $PsFolder | Out-Null;` + $PSVersionTable | Export-Clixml -Path .\OsPsVer.clix;` + } else {Throw 'Installation failed! See c:\Dockerfile.log'} # Verify New Powershell.exe runs -SHELL ["C:\\Program Files\\PowerShell\\Core\\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]!') ; ` - } ; +SHELL ["C:\\Program Files\\PowerShell\\Core\\powershell.exe","-command","$ErrorActionPreference='Stop';"] +RUN $PSVersionTable|Out-Host; $OsPsVer = Import-Clixml -Path .\OsPsVer.clix; Remove-Item -Path .\OsPsVer.clix;` + If ($PSVersionTable.PSEdition -ne 'Core') {Throw [String]$('['+$PSVersionTable.PSEdition+'] is not [Core]!')}` + If ($PSVersionTable.PSVersion -eq $OsPsVer.PSVersion) {Throw [String]$('['+$PSVersionTable.PSVersion+'] is unchanged...')}` + Write-Host "Hello World! PowerShell Core installation has been verfied." -# Persist %PSCORE% ENV variable for user convenience -ENV PSCORE='"C:\Program Files\PowerShell\Core\PowerShell.exe"' +SHELL ["CMD.EXE","/C"] +RUN del /q C:\Dockerfile.log &>c:\entrypoint.bat echo @echo off &>>c:\entrypoint.bat` + echo "C:\Program Files\PowerShell\Core\powershell.exe" -command $ErrorActionPreference='Stop';%* + +ENTRYPOINT ["C:\\Program Files\\PowerShell\\Core\\powershell.exe","-noexit","-command","$ErrorActionPreference='Stop';"] \ No newline at end of file diff --git a/docker/release/windowsservercore/Dockerfile b/docker/release/windowsservercore/Dockerfile index b31d36b84d4..118cf80d875 100644 --- a/docker/release/windowsservercore/Dockerfile +++ b/docker/release/windowsservercore/Dockerfile @@ -1,48 +1,45 @@ # escape=` FROM microsoft/windowsservercore -MAINTAINER brycem@microsoft.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." +LABEL Readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md",` + Description="This Dockerfile will install the latest release of PS." -ARG POWERSHELL_MSI=https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.14/PowerShell_6.0.0.14-alpha.14-win10-x64.msi -ARG POWERSHELL_SHA256=503F3AD52223699765895D3E9615FBD7988194693BCB725BE90C9EF0CD594447 +ARG POWERSHELL_MSI=https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.15/PowerShell_6.0.0-alpha.15-win10-win2k16-x64.msi +ARG POWERSHELL_SHA256=CC52D21F3287E412B9C3B73C98BB5B06F8056D49D63201072216DF92B7F2E59B -# Setup PowerShell - Log-to > C:\Docker.log -SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"] -ADD $POWERSHELL_MSI /PowerShell-win10-x64.msi -ENV POWERSHELL_SHA256=$POWERSHELL_SHA256 +# Prepare shell environment to Log-to > C:\Dockerfile.log +SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","-command","$ErrorActionPreference = 'Stop';","$ConfirmPreference = 'None';",` + "$VerbosePreference = 'Continue';","Start-Transcript -path C:\\Dockerfile.log -append -IncludeInvocationHeader;","$PSVersionTable|Write-Output;",` + "$WinVer = $(Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion');",` + "$OsVer = $('OperatingSystem: '+ $WinVer.ProductName +' '+$WinVer.EditionId+' '+$WinVer.InstallationType);",` + "$BldVer = $('FullBuildString: '+ $WinVer.BuildLabEx); Write-Output -InputObject $OsVer,$BldVer; "] # 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 ; ` - [String]$MsiHash=(Get-FileHash -Path $MSiFile -Algorithm SHA256 | select -ExpandProperty Hash) ; ` - If ($MsiHash -notmatch $Env:POWERSHELL_SHA256) { ` - Throw [String]$('['+$MsiHash+'] does not match ['+$Env:POWERSHELL_SHA256+']!') ` - } ; ` - 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 Core -Value $psexe.DirectoryName ` - } else { throw 'Installation failed! See c:\PowerShell-win10-x64.msi.log' } ; +ADD $POWERSHELL_MSI /PowerShell-win10-win2k16-x64.msi +RUN [System.IO.FileInfo]$MsiFile = Get-Item -Path ./PowerShell-win10-win2k16-x64.msi;` + [String]$MsiHash=(Get-FileHash -Path $MSiFile -Algorithm SHA256 | select -ExpandProperty Hash);` + If ($MsiHash -notmatch $Env:POWERSHELL_SHA256) {` + Throw [String]$('['+$MsiHash+'] does not match ['+$Env:POWERSHELL_SHA256+']!') ` + }` + $proc=Start-Process -FilePath msiexec.exe -ArgumentList '-qn','-i c:\PowerShell-win10-win2k16-x64.msi',` + '-log c:\PowerShell-win10-win2k16-x64.msi.log','-norestart' -wait -PassThru;` + If ($proc.ExitCode -eq 0) {` + Remove-Item -Path $MsiFile;` + $psexe=Get-Item -Path $Env:ProgramFiles\PowerShell\*\powershell.exe;` + Write-Host ('Successfully installed to '+$psexe);` + New-Item -Type SymbolicLink -Path $Env:ProgramFiles\PowerShell\ -Name Core ` + -Value $psexe.DirectoryName | Out-Null;` + $PSVersionTable | Export-Clixml -Path .\OsPsVer.clix;` + } else { throw 'Installation failed! See c:\PowerShell-win10-win2k16-x64.msi.log'} # Verify New Powershell.exe runs -SHELL ["C:\\Program Files\\PowerShell\\Core\\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]!') ; ` - } ; +SHELL ["C:\\Program Files\\PowerShell\\Core\\powershell.exe","-command","$ErrorActionPreference='Stop';"] +RUN $PSVersionTable|Out-Host; $OsPsVer = Import-Clixml -Path .\OsPsVer.clix; Remove-Item -Path .\OsPsVer.clix;` + If ($PSVersionTable.PSEdition -ne 'Core') {Throw [String]$('['+$PSVersionTable.PSEdition+'] is not [Core]!')}` + If ($PSVersionTable.PSVersion -eq $OsPsVer.PSVersion) {Throw [String]$('['+$PSVersionTable.PSVersion+'] is unchanged...')}` + Write-Host "Hello World! PowerShell Core installation has been verfied." -# Persist %PSCORE% ENV variable for user convenience -ENV PSCORE='"C:\Program Files\PowerShell\Core\PowerShell.exe"' +SHELL ["CMD.EXE","/C"] +RUN del /q C:\Dockerfile.log &>c:\entrypoint.bat echo @echo off &>>c:\entrypoint.bat` + echo "C:\Program Files\PowerShell\Core\powershell.exe" -command $ErrorActionPreference='Stop';%* + +ENTRYPOINT ["C:\\Program Files\\PowerShell\\Core\\powershell.exe","-noexit","-command","$ErrorActionPreference='Stop';"] \ No newline at end of file