Skip to content

Commit bd9f012

Browse files
TravisEz13daviwil
authored andcommitted
add windows server core image
1 parent c3933cc commit bd9f012

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[cmdletbinding()]
2+
# PowerShell Script to clone, build and package PowerShell from specified fork and branch
3+
param (
4+
[string] $location = "$pwd\vscode-powershell",
5+
[string] $destination = "$env:WORKSPACE",
6+
[switch] $Wait
7+
)
8+
9+
if(-not $env:homedrive)
10+
{
11+
Write-Verbose "fixing empty home paths..." -Verbose
12+
$profileParts = $env:userprofile -split ':'
13+
$env:homedrive = $profileParts[0]+':'
14+
$env:homepath = $profileParts[1]
15+
}
16+
17+
if(! (Test-Path $destination))
18+
{
19+
Write-Verbose "Creating destination $destination" -Verbose
20+
$null = New-Item -Path $destination -ItemType Directory
21+
}
22+
23+
#BUG BUG: External binaries should be retrieved via nuget package or similar
24+
$editorServicesPath = Join-Path $location -ChildPath '..\PowerShellEditorServices'
25+
git clone --quiet https://github.com/PowerShell/PowerShellEditorServices $editorServicesPath
26+
27+
Write-Verbose "homedrive : ${env:homedrive}"
28+
Write-Verbose "homepath : ${env:homepath}"
29+
30+
# Don't use CIM_PhysicalMemory, docker containers may cache old values
31+
$memoryMB = (Get-CimInstance win32_computersystem).TotalPhysicalMemory /1MB
32+
$requiredMemoryMB = 2048
33+
if($memoryMB -lt $requiredMemoryMB)
34+
{
35+
throw "Building powershell requires at least $requiredMemoryMB MiB of memory and only $memoryMB MiB is present."
36+
}
37+
Write-Verbose "Running with $memoryMB MB memory." -Verbose
38+
39+
try{
40+
Install-Module InvokeBuild -Scope CurrentUser
41+
Import-module InvokeBuild -Verbose
42+
Set-Location $location
43+
44+
Invoke-Build
45+
46+
Get-ChildItem $location\PowerShell-*.vsix | Select-Object -ExpandProperty FullName | ForEach-Object {
47+
$file = $_
48+
Write-Verbose "Copying $file to $destination" -verbose
49+
Copy-Item -Path $file -Destination "$destination\" -Force
50+
}
51+
}
52+
finally
53+
{
54+
Write-Verbose "Beginning build clean-up..." -verbose
55+
if($Wait.IsPresent)
56+
{
57+
$path = Join-Path $PSScriptRoot -ChildPath 'delete-to-continue.txt'
58+
$null = New-Item -Path $path -ItemType File
59+
Write-Verbose "Computer name: $env:COMPUTERNAME" -Verbose
60+
Write-Verbose "Delete $path to exit." -Verbose
61+
while(Test-Path -LiteralPath $path)
62+
{
63+
Start-Sleep -Seconds 60
64+
}
65+
}
66+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# escape=`
2+
FROM microsoft/windowsservercore
3+
LABEL maintainer='PowerShell Team <powershellteam@hotmail.com>'
4+
LABEL version="0.3"
5+
6+
SHELL ["PowerShell.exe", "-command"]
7+
8+
RUN Set-ExecutionPolicy Unrestricted
9+
RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
10+
RUN Get-PackageProvider -Name nuget -ForceBootstrap
11+
RUN Install-Module InvokeBuild -Force
12+
RUN choco install -y nodejs.install --no-progress
13+
RUN choco install -y git.install --no-progress
14+
RUN choco install -y netfx-4.5.1-devpack --no-progress; exit 0
15+
16+
COPY ./Build.ps1 /build.ps1
17+
18+
ENTRYPOINT ["powershell", "-executionpolicy", "unrestricted"]

0 commit comments

Comments
 (0)