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