Adds an end-to-end Python debug workflow for the extension. Includes a new prepare-debug.ps1 script and a VS Code task. Extends the Python server and extension to coordinate a debug session and safe startup. - Add prepare-debug.ps1 and a VS Code task to build the debug bundle - Enable Python debug wiring in the server and tests - Ensure a single stable Python debug session during startup
58 lines
2.0 KiB
PowerShell
58 lines
2.0 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$WorkspaceRoot,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$DebugRoot
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function ConvertFrom-ExtendedWindowsPath {
|
|
param([string]$Path)
|
|
|
|
if ($Path.StartsWith("\\?\UNC\", [System.StringComparison]::OrdinalIgnoreCase)) {
|
|
return "\\" + $Path.Substring(8)
|
|
}
|
|
if ($Path.StartsWith("\\?\", [System.StringComparison]::OrdinalIgnoreCase)) {
|
|
return $Path.Substring(4)
|
|
}
|
|
return $Path
|
|
}
|
|
|
|
$workspacePath = ConvertFrom-ExtendedWindowsPath $WorkspaceRoot
|
|
$workspaceItem = Get-Item -LiteralPath $workspacePath
|
|
if (-not $workspaceItem.PSIsContainer) {
|
|
throw "Workspace root is not a directory: $workspacePath"
|
|
}
|
|
$workspacePath = $workspaceItem.FullName
|
|
|
|
$debugPath = ConvertFrom-ExtendedWindowsPath $DebugRoot
|
|
$tempPath = [System.IO.Path]::GetFullPath([System.IO.Path]::GetTempPath()).TrimEnd("\")
|
|
$debugParent = [System.IO.Path]::GetFullPath((Split-Path -Parent $debugPath)).TrimEnd("\")
|
|
if (-not $debugParent.Equals($tempPath, [System.StringComparison]::OrdinalIgnoreCase)) {
|
|
throw "Debug alias must be located directly below the user temp directory: $debugPath"
|
|
}
|
|
|
|
if (Test-Path -LiteralPath $debugPath) {
|
|
$debugItem = Get-Item -LiteralPath $debugPath -Force
|
|
if ($debugItem.LinkType -ne "Junction") {
|
|
throw "Debug alias exists but is not a junction: $debugPath"
|
|
}
|
|
|
|
$currentTarget = (Get-Item -LiteralPath $debugItem.Target).FullName
|
|
if (-not $currentTarget.Equals($workspacePath, [System.StringComparison]::OrdinalIgnoreCase)) {
|
|
# Removing a junction removes only the link, never the target directory.
|
|
Remove-Item -LiteralPath $debugPath -Force
|
|
}
|
|
}
|
|
|
|
if (-not (Test-Path -LiteralPath $debugPath)) {
|
|
New-Item -ItemType Junction -Path $debugPath -Target $workspacePath | Out-Null
|
|
}
|
|
|
|
Write-Output "Debug extension path: $debugPath -> $workspacePath"
|
|
& npm.cmd --prefix $workspacePath run compile:debug
|
|
exit $LASTEXITCODE
|