Skip to content

Commit 8943d53

Browse files
TylerLeonhardtRobert Holt
authored and
Robert Holt
committed
Add release build infrastructure
* VSTS configuration * Docker files
1 parent 8778deb commit 8943d53

File tree

8 files changed

+268
-2
lines changed

8 files changed

+268
-2
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ module/PSScriptAnalyzer
3232
docs/_site/
3333
docs/_repo/
3434
docs/metadata/
35-
tools/
3635
*.zip
3736

3837
# quickbuild.exe

PowerShellEditorServices.build.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ task UploadArtifacts -If ($script:IsCIBuild) {
330330
Push-AppveyorArtifact .\src\PowerShellEditorServices.Protocol\bin\$Configuration\Microsoft.PowerShell.EditorServices.Protocol.$($script:FullVersion).nupkg
331331
Push-AppveyorArtifact .\src\PowerShellEditorServices.Host\bin\$Configuration\Microsoft.PowerShell.EditorServices.Host.$($script:FullVersion).nupkg
332332
Push-AppveyorArtifact .\PowerShellEditorServices-$($script:FullVersion).zip
333-
}
333+
}# elseif ($env:TF_BUILD) {
334+
#
335+
# }
334336
}
335337

336338
# The default task is to run the entire CI build

tools/releaseBuild/Image/DockerFile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# escape=`
2+
#0.3.6 (no powershell 6)
3+
FROM microsoft/dotnet-framework:4.7.1
4+
LABEL maintainer='PowerShell Team <powershellteam@hotmail.com>'
5+
LABEL description="Build's PowerShell Editor Services"
6+
7+
SHELL ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
8+
9+
COPY dockerInstall.psm1 containerFiles/dockerInstall.psm1
10+
11+
RUN Import-Module PackageManagement; `
12+
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; `
13+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null; `
14+
Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1 -outfile C:/dotnet-install.ps1; `
15+
C:/dotnet-install.ps1 -Channel Release -Version 2.1.4; `
16+
Add-Path C:/Users/ContainerAdministrator/AppData/Local/Microsoft/dotnet; `
17+
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force; `
18+
Install-Module platyPS -RequiredVersion 0.9.0 -Scope CurrentUser -Force;
19+
20+
# Install .NET Framework 4.5.1 & 4.5.2 Developer Packs
21+
RUN Import-Module ./containerFiles/dockerInstall.psm1; `
22+
Install-ChocolateyPackage -PackageName netfx-4.5.1-devpack; `
23+
Install-ChocolateyPackage -PackageName netfx-4.5.2-devpack;
24+
25+
# Copy build script over
26+
COPY build.ps1 containerFiles/build.ps1
27+
28+
# Uncomment to debug locally
29+
# RUN Import-Module ./containerFiles/dockerInstall.psm1; `
30+
# Install-ChocolateyPackage -PackageName git -Executable git.exe; `
31+
# git clone https://github.com/PowerShell/PowerShellEditorServices;
32+
33+
ENTRYPOINT ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
34+

tools/releaseBuild/Image/build.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
param ( [string]$target )
2+
if ( ! (test-path ${target} ) ) {
3+
new-item -type directory ${target}
4+
}
5+
else {
6+
if ( test-path -pathtype leaf ${target} ) {
7+
remove-item -force ${target}
8+
new-item -type directory ${target}
9+
}
10+
}
11+
push-location C:/PowerShellEditorServices
12+
Invoke-Build -Configuration Release
13+
Copy-Item -Verbose -Recurse "C:/PowerShellEditorServices/module" "${target}/PowerShellEditorServices"
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
function Install-ChocolateyPackage
2+
{
3+
param(
4+
[Parameter(Mandatory=$true)]
5+
[string]
6+
$PackageName,
7+
8+
[Parameter(Mandatory=$false)]
9+
[string]
10+
$Executable,
11+
12+
[string[]]
13+
$ArgumentList,
14+
15+
[switch]
16+
$Cleanup,
17+
18+
[int]
19+
$ExecutionTimeout = 2700,
20+
21+
[string]
22+
$Version
23+
)
24+
25+
if(-not(Get-Command -name Choco -ErrorAction SilentlyContinue))
26+
{
27+
Write-Verbose "Installing Chocolatey provider..." -Verbose
28+
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
29+
}
30+
31+
Write-Verbose "Installing $PackageName..." -Verbose
32+
$extraCommand = @()
33+
if($Version)
34+
{
35+
$extraCommand += '--version', $version
36+
}
37+
choco install -y $PackageName --no-progress --execution-timeout=$ExecutionTimeout $ArgumentList $extraCommands
38+
39+
if($executable)
40+
{
41+
Write-Verbose "Verifing $Executable is in path..." -Verbose
42+
$exeSource = $null
43+
$exeSource = Get-ChildItem -path "$env:ProgramFiles\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName
44+
if(!$exeSource)
45+
{
46+
Write-Verbose "Falling back to x86 program files..." -Verbose
47+
$exeSource = Get-ChildItem -path "${env:ProgramFiles(x86)}\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName
48+
}
49+
50+
# Don't search the chocolatey program data until more official locations have been searched
51+
if(!$exeSource)
52+
{
53+
Write-Verbose "Falling back to chocolatey..." -Verbose
54+
$exeSource = Get-ChildItem -path "$env:ProgramData\chocolatey\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName
55+
}
56+
57+
# all obvious locations are exhausted, use brute force and search from the root of the filesystem
58+
if(!$exeSource)
59+
{
60+
Write-Verbose "Falling back to the root of the drive..." -Verbose
61+
$exeSource = Get-ChildItem -path "/$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName
62+
}
63+
64+
if(!$exeSource)
65+
{
66+
throw "$Executable not found"
67+
}
68+
69+
$exePath = Split-Path -Path $exeSource
70+
Add-Path -path $exePath
71+
}
72+
73+
if($Cleanup.IsPresent)
74+
{
75+
Remove-Folder -Folder "$env:temp\chocolatey"
76+
}
77+
}
78+
79+
function Add-Path
80+
{
81+
param
82+
(
83+
$path
84+
)
85+
$machinePathString = [System.Environment]::GetEnvironmentVariable('path',[System.EnvironmentVariableTarget]::Machine)
86+
$machinePath = $machinePathString -split ';'
87+
88+
if($machinePath -inotcontains $path)
89+
{
90+
$newPath = "$machinePathString;$path"
91+
Write-Verbose "Adding $path to path..." -Verbose
92+
[System.Environment]::SetEnvironmentVariable('path',$newPath,[System.EnvironmentVariableTarget]::Machine)
93+
Write-Verbose "Added $path to path." -Verbose
94+
$env:Path += ";$newPath"
95+
}
96+
else
97+
{
98+
Write-Verbose "$path already in path." -Verbose
99+
}
100+
}
101+
102+
function Remove-Folder
103+
{
104+
param(
105+
[string]
106+
$Folder
107+
)
108+
109+
Write-Verbose "Cleaning up $Folder..." -Verbose
110+
$filter = Join-Path -Path $Folder -ChildPath *
111+
[int]$measuredCleanupMB = (Get-ChildItem $filter -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB
112+
Remove-Item -recurse -force $filter -ErrorAction SilentlyContinue
113+
Write-Verbose "Cleaned up $measuredCleanupMB MB from $Folder" -Verbose
114+
}

tools/releaseBuild/build.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"Windows": {
3+
"Name": "win7-x64",
4+
"RepoDestinationPath": "C:\\PowerShellEditorServices",
5+
"BuildCommand": "C:\\containerFiles\\build.ps1 -target _DockerVolume_",
6+
"DockerFile": ".\\tools\\releaseBuild\\Image\\DockerFile",
7+
"DockerImageName": "powershelleditorservices",
8+
"BinaryBucket": "release",
9+
"PublishAsFolder": true,
10+
"AdditionalContextFiles" : [
11+
".\\tools\\releaseBuild\\Image\\build.ps1",
12+
".\\tools\\releaseBuild\\Image\\dockerInstall.psm1"
13+
]
14+
}
15+
}

tools/releaseBuild/signing.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<SignConfigXML>
3+
<!-- ****Begin**** BothDual - Dual (Sha256 and Sha1) AuthenticodeDual) and should be StrongName, but we will add this in 6.1.0 ******** -->
4+
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Standard Library" approvers="vigarg;gstolt">
5+
<file src="__INPATHROOT__\release\out\Microsoft.PowerShell.Standard.Module.Template.0.1.1.nupkg" signType="CP-401405"
6+
dest="__OUTPATHROOT__\release\out\Microsoft.PowerShell.Standard.Module.Template.0.1.1.nupkg" />
7+
<file src="__INPATHROOT__\release\out\PowerShellStandard.Library.3.0.0-preview-02.nupkg" signType="CP-401405"
8+
dest="__OUTPATHROOT__\release\out\PowerShellStandard.Library.3.0.0-preview-02.nupkg" />
9+
<file src="__INPATHROOT__\release\out\PowerShellStandard.Library.5.1.0-preview-04.nupkg" signType="CP-401405"
10+
dest="__OUTPATHROOT__\release\out\PowerShellStandard.Library.5.1.0-preview-04.nupkg" />
11+
</job>
12+
</SignConfigXML>
13+
14+
15+
16+

tools/releaseBuild/vstsbuild.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[cmdletbinding()]
2+
param()
3+
4+
Begin
5+
{
6+
$ErrorActionPreference = 'Stop'
7+
8+
$gitBinFullPath = (Get-Command -Name git -CommandType Application).Path | Select-Object -First 1
9+
if ( ! $gitBinFullPath )
10+
{
11+
throw "Git is missing! Install from 'https://git-scm.com/download/win'"
12+
}
13+
14+
# clone the release tools
15+
$releaseToolsDirName = "PSRelease"
16+
$releaseToolsLocation = Join-Path -Path $PSScriptRoot -ChildPath PSRelease
17+
if ( Test-Path $releaseToolsLocation )
18+
{
19+
Remove-Item -Force -Recurse -Path $releaseToolsLocation
20+
}
21+
& $gitBinFullPath clone -b master --quiet https://github.com/PowerShell/${releaseToolsDirName}.git $releaseToolsLocation
22+
Import-Module "$releaseToolsLocation/vstsBuild" -Force
23+
Import-Module "$releaseToolsLocation/dockerBasedBuild" -Force -Prefix DockerBased
24+
}
25+
26+
End {
27+
28+
$AdditionalFiles = .{
29+
Join-Path $PSScriptRoot -child "Image/build.ps1"
30+
Join-Path $PSScriptRoot -child "Image/dockerInstall.psm1"
31+
}
32+
$buildPackageName = $null
33+
34+
# defined if building in VSTS
35+
if($env:BUILD_STAGINGDIRECTORY)
36+
{
37+
# Use artifact staging if running in VSTS
38+
$destFolder = $env:BUILD_STAGINGDIRECTORY
39+
}
40+
else
41+
{
42+
# Use temp as destination if not running in VSTS
43+
$destFolder = $env:temp
44+
}
45+
46+
$resolvedRepoRoot = (Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "../../")).Path
47+
48+
try
49+
{
50+
Write-Verbose "Starting build at $resolvedRepoRoot ..." -Verbose
51+
Clear-VstsTaskState
52+
53+
$buildParameters = @{
54+
ReleaseTag = $ReleaseTag
55+
}
56+
$buildArgs = @{
57+
RepoPath = $resolvedRepoRoot
58+
BuildJsonPath = './tools/releaseBuild/build.json'
59+
Parameters = $buildParameters
60+
AdditionalFiles = $AdditionalFiles
61+
Name = "win7-x64"
62+
}
63+
Invoke-DockerBasedBuild @buildArgs
64+
}
65+
catch
66+
{
67+
Write-VstsError -Error $_
68+
}
69+
finally{
70+
Write-VstsTaskState
71+
exit 0
72+
}
73+
}

0 commit comments

Comments
 (0)