From 610fb45ec303482c6a912233e31e672b8ff157db Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 23 Aug 2016 16:44:28 -0700 Subject: [PATCH 1/5] Fix extension load issue with spaces in usernames This change fixes #244 which reports that the extension does not load when the user's username contains a space. This was caused by the script execution of Start-EditorServices.ps1 not being contained within quotes. --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 0f2a9bbe66..78109ddf10 100644 --- a/src/main.ts +++ b/src/main.ts @@ -177,7 +177,7 @@ function startPowerShell(powerShellExePath: string, bundledModulesPath: string, // Add the Start-EditorServices.ps1 invocation arguments args.push('-Command') - args.push(startScriptPath + ' ' + startArgs) + args.push('& "' + startScriptPath + '" ' + startArgs) // Launch PowerShell as child process powerShellProcess = cp.spawn(powerShellExePath, args); From 40bca0aab10123334be2bed26c6582afa7a619c9 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 23 Aug 2016 16:46:28 -0700 Subject: [PATCH 2/5] Update PowerShell Editor Services version --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 78109ddf10..76f4923b2e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,7 +25,7 @@ import net = require('net'); // NOTE: We will need to find a better way to deal with the required // PS Editor Services version... -var requiredEditorServicesVersion = "0.7.0"; +var requiredEditorServicesVersion = "0.7.1"; var powerShellProcess: cp.ChildProcess = undefined; var languageServerClient: LanguageClient = undefined; From 3246362e8ee93097d6bf0398be8aa12f148576be Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 23 Aug 2016 16:46:44 -0700 Subject: [PATCH 3/5] Remove PSv3-incompatible lines from startup script This change fixes #248 which reports that the extension cannot be loaded on Windows 7 machines running PowerShell v3 (and probably also any machine running PowerShell v4). The Start-EditorServices.ps1 script relied in features only present in PowerShell v5. New code paths have been added to the script to make it compatible with v3 and v4. --- scripts/Start-EditorServices.ps1 | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/scripts/Start-EditorServices.ps1 b/scripts/Start-EditorServices.ps1 index 4b343135b5..f447f20208 100644 --- a/scripts/Start-EditorServices.ps1 +++ b/scripts/Start-EditorServices.ps1 @@ -54,6 +54,9 @@ param( $ConfirmInstall ) +# Are we running in PowerShell 5 or later? +$isPS5orLater = $PSVersionTable.PSVersion.Major -ge 5 + # This variable will be assigned later to contain information about # what happened while attempting to launch the PowerShell Editor # Services host @@ -81,8 +84,14 @@ function Test-PortAvailability($PortNumber) { $portAvailable = $true; try { - $ipAddress = [System.Net.Dns]::GetHostEntryAsync("localhost").Result.AddressList[0]; - $tcpListener = [System.Net.Sockets.TcpListener]::new($ipAddress, $portNumber); + if ($isPS5orLater) { + $ipAddress = [System.Net.Dns]::GetHostEntryAsync("localhost").Result.AddressList[0]; + } + else { + $ipAddress = [System.Net.Dns]::GetHostEntry("localhost").AddressList[0]; + } + + $tcpListener = New-Object System.Net.Sockets.TcpListener @($ipAddress, $portNumber) $tcpListener.Start(); $tcpListener.Stop(); @@ -100,7 +109,7 @@ function Test-PortAvailability($PortNumber) { return $portAvailable; } -$rand = [System.Random]::new() +$rand = New-Object System.Random function Get-AvailablePort { $triesRemaining = 10; @@ -128,9 +137,9 @@ if ((Test-ModuleAvailable "PowerShellGet") -eq $false) { # Check if the expected version of the PowerShell Editor Services # module is installed -$parsedVersion = [System.Version]::new($EditorServicesVersion) +$parsedVersion = New-Object System.Version @($EditorServicesVersion) if ((Test-ModuleAvailable "PowerShellEditorServices" -RequiredVersion $parsedVersion) -eq $false) { - if ($ConfirmInstall) { + if ($ConfirmInstall -and $isPS5orLater) { # TODO: Check for error and return failure if necessary Install-Module "PowerShellEditorServices" -RequiredVersion $parsedVersion -Confirm } @@ -141,7 +150,12 @@ if ((Test-ModuleAvailable "PowerShellEditorServices" -RequiredVersion $parsedVer } } -Import-Module PowerShellEditorServices -RequiredVersion $parsedVersion -ErrorAction Stop +if ($isPS5orLater) { + Import-Module PowerShellEditorServices -RequiredVersion $parsedVersion -ErrorAction Stop +} +else { + Import-Module PowerShellEditorServices -Version $parsedVersion -ErrorAction Stop +} # Locate available port numbers for services $languageServicePort = Get-AvailablePort From 28afd8e0996bd3d2f5e12350a450be2c94b28a05 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 23 Aug 2016 16:48:48 -0700 Subject: [PATCH 4/5] Update README.md to include supported platforms --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bc7ecaea08..a320b6fa3b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,16 @@ This extension provides rich PowerShell language support for Visual Studio Code. Now you can write and debug PowerShell scripts using the excellent IDE-like interface -that VS Code provides. +that Visual Studio Code provides. + +## Platform support + +- **Windows 7 through 10** with PowerShell v3 and higher +- **Linux** with PowerShell v6 (all PowerShell-supported distribtions) +- **Mac OS X** with PowerShell v6 + +Read the [installation instructions](https://github.com/PowerShell/PowerShell/blob/master/docs/learning-powershell/using-vscode.md) +to get more details on how to use the extension on these platforms. ## Features From cef43ca5c033e0e2fec46eef64fbf41cf9fe3619 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 23 Aug 2016 16:49:24 -0700 Subject: [PATCH 5/5] Bump version to 0.7.1, update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cea1bc9247..11405f0d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # vscode-powershell Release History +## 0.7.1 +### Tuesday, August 23, 2016 + +- "Auto" variable scope in debugger UI now expands by default +- Fixed #244: Extension fails to load if username contains spaces +- Fixed #246: Restore default PSScriptAnalyzer ruleset +- Fixed #248: Extension fails to load on Windows 7 with PowerShell v3 + ## 0.7.0 ### Thursday, August 18, 2016 diff --git a/package.json b/package.json index c9aa04bca4..b0cd293dd4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "PowerShell", "displayName": "PowerShell", - "version": "0.7.0", + "version": "0.7.1", "publisher": "ms-vscode", "description": "Develop PowerShell scripts in Visual Studio Code!", "engines": {