forked from PowerShell/vscode-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvscode-powershell.build.ps1
115 lines (89 loc) · 3.69 KB
/
vscode-powershell.build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
param(
[string]$EditorServicesRepoPath = $null
)
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.0.0"}
$script:IsPullRequestBuild =
$env:APPVEYOR_PULL_REQUEST_NUMBER -and
$env:APPVEYOR_REPO_BRANCH -eq "develop"
task GetExtensionVersion -Before Package {
$updateVersion = $false
$script:ExtensionVersion = `
if ($env:AppVeyor) {
$updateVersion = $true
$env:APPVEYOR_BUILD_VERSION
}
else {
exec { & npm version | ConvertFrom-Json | ForEach-Object { $_.PowerShell } }
}
Write-Host "`n### Extension Version: $script:ExtensionVersion`n" -ForegroundColor Green
if ($updateVersion) {
exec { & npm version $script:ExtensionVersion --no-git-tag-version }
}
}
task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices {
$script:psesRepoPath = `
if ($EditorServicesRepoPath) {
$EditorServicesRepoPath
}
else {
"$PSScriptRoot/../PowerShellEditorServices/"
}
if (!(Test-Path $script:psesRepoPath)) {
# Clear the path so that it won't be used
Write-Host "`n### WARNING: The PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n" -ForegroundColor Yellow
$script:psesRepoPath = $null
}
else {
$script:psesRepoPath = Resolve-Path $script:psesRepoPath
$script:psesBuildScriptPath = Resolve-Path "$script:psesRepoPath/PowerShellEditorServices.build.ps1"
}
}
task Restore -If { "Restore" -in $BuildTask -or !(Test-Path "./node_modules") } -Before Build {
Write-Host "`n### Restoring vscode-powershell dependencies`n" -ForegroundColor Green
# When in a CI build use the --loglevel=error parameter so that
# package install warnings don't cause PowerShell to throw up
$logLevelParam = if ($env:AppVeyor) { "--loglevel=error" } else { "" }
exec { & npm install $logLevelParam }
}
task Clean {
Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
Remove-Item .\out -Recurse -Force -ErrorAction Ignore
}
task CleanEditorServices {
if ($script:psesBuildScriptPath) {
Write-Host "`n### Cleaning PowerShellEditorServices`n" -ForegroundColor Green
Invoke-Build Clean $script:psesBuildScriptPath
}
}
task CleanAll CleanEditorServices, Clean
task Build {
Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
exec { & npm run compile }
}
task BuildEditorServices {
# If the PSES codebase is co-located, build it first
if ($script:psesBuildScriptPath) {
Write-Host "`n### Building PowerShellEditorServices`n" -ForegroundColor Green
Invoke-Build Build $script:psesBuildScriptPath
}
}
task BuildAll BuildEditorServices, Build -Before Package
task Package {
if ($script:psesBuildScriptPath) {
Write-Host "`n### Copying PowerShellEditorServices module files" -ForegroundColor Green
Copy-Item -Recurse -Force ..\PowerShellEditorServices\module\PowerShellEditorServices .\modules
}
Write-Host "`n### Packaging PowerShell-insiders.vsix`n" -ForegroundColor Green
exec { & node ./node_modules/vsce/out/vsce package }
# Change the package to have a static name for automation purposes
Move-Item .\PowerShell-$($script:ExtensionVersion).vsix .\PowerShell-insiders.vsix
}
task UploadArtifacts -If { $env:AppVeyor } {
Push-AppveyorArtifact .\PowerShell-insiders.vsix
}
# The default task is to run the entire CI build
task . GetExtensionVersion, CleanAll, BuildAll, Package, UploadArtifacts