Skip to content

Commit 8f46a60

Browse files
committed
Add a PowerShell build script and wire it up in tasks.json
This change introduces a new vscode-powershell.build.ps1 script powered by Invoke-Build. The goal of this script is to handle build tasks which would affect both the PowerShell extension and PowerShell Editor Services so that it's much easier to hit F5 and build everything before launching the debugger. This is also a starting point for release automation so we can start shipping faster!
1 parent a7a91a0 commit 8f46a60

File tree

4 files changed

+86
-43
lines changed

4 files changed

+86
-43
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"stopOnEntry": false,
1111
"sourceMaps": true,
1212
"outDir": "${workspaceRoot}/out",
13-
"preLaunchTask": "compile"
13+
"preLaunchTask": "Build"
1414
},
1515
{
1616
"name": "Attach",

.vscode/tasks.json

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,38 @@
1-
// Available variables which can be used inside of strings.
2-
// ${workspaceRoot}: the root folder of the team
3-
// ${file}: the current opened file
4-
// ${fileBasename}: the current opened file's basename
5-
// ${fileDirname}: the current opened file's dirname
6-
// ${fileExtname}: the current opened file's extension
7-
// ${cwd}: the current working directory of the spawned process
8-
9-
// A task runner that calls a custom npm script that compiles the extension.
101
{
11-
"version": "0.1.0",
12-
13-
// we want to run npm
14-
"command": "npm",
15-
16-
// the command is a shell script
17-
"isShellCommand": true,
2+
"version": "0.1.0",
3+
4+
"windows": {
5+
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
6+
"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ]
7+
},
8+
"linux": {
9+
"command": "/usr/bin/powershell",
10+
"args": [ "-NoProfile" ]
11+
},
12+
"osx": {
13+
"command": "/usr/local/bin/powershell",
14+
"args": [ "-NoProfile" ]
15+
},
16+
17+
"isShellCommand": true,
18+
"showOutput": "always",
1819

1920
"tasks": [
2021
{
21-
"taskName": "install",
22-
"showOutput": "always"
22+
"taskName": "Install",
23+
"suppressTaskName": true,
24+
"args": [ "Invoke-Build Restore" ]
2325
},
2426
{
25-
"taskName": "compile",
26-
"isBuildCommand": true,
27+
"taskName": "Clean",
2728
"suppressTaskName": true,
28-
29-
// show the output window only if unrecognized errors occur.
30-
"showOutput": "silent",
31-
32-
// we run the custom script "compile" as defined in package.json
33-
"args": ["run", "compile"],
34-
35-
// use the standard tsc problem matcher to find compile problems in the output.
36-
"problemMatcher": "$tsc"
29+
"args": [ "Invoke-Build Clean" ]
3730
},
3831
{
39-
"taskName": "compile-watch",
32+
"taskName": "Build",
4033
"suppressTaskName": true,
41-
42-
// show the output window only if unrecognized errors occur.
43-
"showOutput": "silent",
44-
45-
// we run the custom script "compile-watch" as defined in package.json
46-
"args": ["run", "compile-watch"],
47-
48-
// The tsc compiler is started in watching mode
49-
"isWatching": true,
50-
51-
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
52-
"problemMatcher": "$tsc-watch"
34+
"isBuildCommand": true,
35+
"args": [ "Invoke-Build Build" ]
5336
}
5437
]
5538
}

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vscode/**
2+
vscode-powershell.build.ps1
23
typings/**
34
**/*.ts
45
.gitignore

vscode-powershell.build.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#
2+
# Copyright (c) Microsoft. All rights reserved.
3+
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
4+
#
5+
6+
param(
7+
[string]$EditorServicesRepoPath = $null
8+
)
9+
10+
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}
11+
12+
task ResolveEditorServicesPath -Before Clean, Build {
13+
$script:psesRepoPath = `
14+
if ($EditorServicesRepoPath) {
15+
$EditorServicesRepoPath
16+
}
17+
else {
18+
"$PSScriptRoot/../PowerShellEditorServices/"
19+
}
20+
21+
if (!(Test-Path $script:psesRepoPath)) {
22+
# Clear the path so that it won't be used
23+
Write-Host "`n### WARNING: The PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n" -ForegroundColor Yellow
24+
$script:psesRepoPath = $null
25+
}
26+
else {
27+
$script:psesRepoPath = Resolve-Path $script:psesRepoPath
28+
$script:psesBuildScriptPath = Resolve-Path "$script:psesRepoPath/PowerShellEditorServices.build.ps1"
29+
}
30+
}
31+
32+
task Restore -If { "Restore" -in $BuildTasks -or !(Test-Path "./node_modules") } -Before Build {
33+
Write-Host "`n### Restoring vscode-powershell dependencies, this could take a while`n" -ForegroundColor Green
34+
exec { & npm install }
35+
}
36+
37+
task Clean {
38+
if ($script:psesBuildScriptPath) {
39+
Write-Host "`n### Cleaning PowerShellEditorServices`n" -ForegroundColor Green
40+
Invoke-Build Clean $script:psesBuildScriptPath
41+
}
42+
43+
Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
44+
Remove-Item .\out -Recurse -Force -ErrorAction Ignore
45+
}
46+
47+
task Build {
48+
49+
# If the PSES codebase is co-located, build it first
50+
if ($script:psesBuildScriptPath) {
51+
Write-Host "`n### Building PowerShellEditorServices`n" -ForegroundColor Green
52+
Invoke-Build BuildHost $script:psesBuildScriptPath
53+
}
54+
55+
Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
56+
exec { & npm run compile }
57+
}
58+
59+
task . Clean, Build

0 commit comments

Comments
 (0)