Skip to content

Commit 0dc8035

Browse files
Use --follow-symlinks in VSCE package command and simplify build logic (#5212)
* Initial plan for issue * Add --follow-symlinks flag to VSCE and simplify build logic * Add --follow-symlinks flag to vsce publish command * Address review feedback: remove --follow-symlinks from publish, simplify build logic, add assertion * Remove conditional check and always call Invoke-Build --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: andyleejordan <[email protected]>
1 parent 5bacca5 commit 0dc8035

File tree

2 files changed

+11
-42
lines changed

2 files changed

+11
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"watch": "npm run compile -- --watch",
104104
"lint": "eslint src test --ext .ts",
105105
"format": "prettier --check '**/*.{ts,json,yml,mjs,code-workspace}'",
106-
"package": "vsce package --out out/ --no-gitHubIssueLinking",
106+
"package": "vsce package --out out/ --no-gitHubIssueLinking --follow-symlinks",
107107
"publish": "vsce publish",
108108
"pretest": "npm run compile",
109109
"test": "vscode-test"

vscode-powershell.build.ps1

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,16 @@ task RestoreNodeOptional -If { !(Test-Path ./node_modules/eslint) } {
3333
}
3434

3535
task RestoreEditorServices -If (Get-EditorServicesPath) {
36-
switch ($Configuration) {
37-
"Debug" {
38-
# When debugging, we always rebuild PSES and ensure its symlinked so
39-
# that developers always have the latest local bits.
40-
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -ne "SymbolicLink") {
41-
Write-Build DarkMagenta "Creating symbolic link to PSES"
42-
Remove-BuildItem ./modules
43-
New-Item -ItemType SymbolicLink -Path ./modules -Target "$(Split-Path (Get-EditorServicesPath))/module"
44-
}
45-
46-
Write-Build DarkGreen "Building PSES"
47-
Invoke-Build Build (Get-EditorServicesPath) -Configuration $Configuration
48-
}
49-
"Release" {
50-
# When releasing, we ensure the bits are not symlinked but copied,
51-
# and only if they don't already exist.
52-
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") {
53-
Write-Build DarkRed "Deleting PSES symbolic link"
54-
Remove-BuildItem ./modules
55-
}
56-
57-
if (!(Test-Path ./modules)) {
58-
# We only build if it hasn't been built at all.
59-
if (!(Test-Path "$(Split-Path (Get-EditorServicesPath))/module/PowerShellEditorServices/bin")) {
60-
Write-Build DarkGreen "Building PSES"
61-
Invoke-Build Build (Get-EditorServicesPath) -Configuration $Configuration
62-
}
63-
64-
Write-Build DarkGreen "Copying PSES"
65-
Copy-Item -Recurse -Force "$(Split-Path (Get-EditorServicesPath))/module" ./modules
66-
}
67-
}
36+
# With VSCE --follow-symlinks support, we can now use symlinks consistently
37+
# for both Debug and Release configurations.
38+
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -ne "SymbolicLink") {
39+
Write-Build DarkMagenta "Creating symbolic link to PSES"
40+
Remove-BuildItem ./modules
41+
New-Item -ItemType SymbolicLink -Path ./modules -Target "$(Split-Path (Get-EditorServicesPath))/module"
6842
}
43+
44+
Write-Build DarkGreen "Building PSES"
45+
Invoke-Build Build (Get-EditorServicesPath) -Configuration $Configuration
6946
}
7047

7148
#endregion
@@ -131,15 +108,7 @@ task Package {
131108
New-Item -ItemType Directory -Force out | Out-Null
132109

133110
Assert-Build (Test-Path ./dist/extension.js) "Extension must be built!"
134-
135-
# Packaging requires a copy of the modules folder, not a symbolic link. But
136-
# we might have built in Debug configuration, not Release, and still want to
137-
# package it. So delete the symlink and copy what we just built.
138-
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") {
139-
Write-Build DarkRed "PSES is a symbolic link, replacing with copy!"
140-
Remove-BuildItem ./modules
141-
Copy-Item -Recurse -Force "$(Split-Path (Get-EditorServicesPath))/module" ./modules
142-
}
111+
Assert-Build (Test-Path ./modules/PowerShellEditorServices/bin) "PowerShell Editor Services must be built under modules!"
143112

144113
if ($version.Minor % 2 -ne 0) {
145114
Write-Build DarkRed "This is a pre-release!"

0 commit comments

Comments
 (0)