From ab3df78a244e1b96118abdf8cbc1cc80d8dcc618 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 18 Jan 2019 18:15:07 -0800 Subject: [PATCH 1/2] upport Preview mechanism --- .github/ISSUE_TEMPLATE/Bug_report.md | 5 ++++ README.md | 8 +++++- docs/development.md | 12 +++++++++ docs/troubleshooting.md | 11 ++++++++ src/features/GenerateBugReport.ts | 4 +-- src/main.ts | 9 +++++-- src/session.ts | 18 +++++++------ tools/releaseBuild/Image/build.ps1 | 2 +- vscode-powershell.build.ps1 | 38 +++++++++++++++++++++++----- 9 files changed, 86 insertions(+), 21 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index 8c7700f054..aac03222ef 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -13,6 +13,11 @@ IMPORTANT: you can generate a bug report directly from the PowerShell extension in Visual Studio Code by selecting "PowerShell: Upload Bug Report to GitHub" from the command palette. +NOTE: If you have both stable (aka "PowerShell") and preview (aka "PowerShell Preview") installed, +you MUST DISABLE one of them for the best performance. +Docs on how to disable an extension can be found here: +https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension + The more repro details you can provide, along with a zip of the log files from your session, the better the chances are for a quick resolution. diff --git a/README.md b/README.md index d26bf7e84f..59c1ab2b73 100644 --- a/README.md +++ b/README.md @@ -88,8 +88,14 @@ how to use them. This folder can be found at the following path: +```powershell +$HOME/.vscode[-insiders]/extensions/ms-vscode.PowerShell-/examples ``` -C:\Users\\.vscode\extensions\ms-vscode.PowerShell-\examples + +or if you're using the preview version of the extension + + ```powershell +$HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-preview-/examples ``` To open/view the extension's examples in Visual Studio Code, run the following from your PowerShell command prompt: diff --git a/docs/development.md b/docs/development.md index a5fe46e91b..3d29c8d5bc 100644 --- a/docs/development.md +++ b/docs/development.md @@ -44,3 +44,15 @@ press Ctrl+F5 or Cmd+F5 on macOS. ``` code --extensionDevelopmentPath="c:\path\to\vscode-powershell" . ``` + +## Building a "Preview" version + +To build a preview version of the extension, that is to say, +a version of the extension named "PowerShell Preview", +You can simply change the version in the package.json to include `-preview` at the end. +When you build, this will: + +- Add a warning to the top of the README.md to warn users not to have the stable and preview version enabled at the same time +- Adds "Preview" in a few places in the package.json + +This mechanism is mostly used for releases. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 1104da371d..83a4f79e79 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -34,6 +34,11 @@ and you can ask for new features [in their repository](https://github.com/Micros ## Known Issues in the Extension +- If you are running the Preview version "PowerShell Preview" side-by-side with the stable version "PowerShell" + you will experience performance and debug issues. + This is expected until VSCode offers extension channels - [vscode#15756](https://github.com/Microsoft/vscode/issues/15756) + - You MUST [DISABLE](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) one of them for the best performance. + Docs on how to disable an extension can be found [here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) - Highlighting/completions/command history don't work as I expect in the Integrated Console - [#535] - The Integrated Console implements a [custom host] @@ -157,6 +162,12 @@ Logs provide context for what was happening when the issue occurred $HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-/logs/ ``` + or if you're using the preview version of the extension + + ```powershell + $HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-preview-/logs/ + ``` + For example: ```powershell diff --git a/src/features/GenerateBugReport.ts b/src/features/GenerateBugReport.ts index 38d52bc2fd..c5954b2d3e 100644 --- a/src/features/GenerateBugReport.ts +++ b/src/features/GenerateBugReport.ts @@ -9,8 +9,6 @@ import { IFeature, LanguageClient } from "../feature"; import { SessionManager } from "../session"; import Settings = require("../settings"); -const extensionId: string = "ms-vscode.PowerShell"; -const extensionVersion: string = vscode.extensions.getExtension(extensionId).packageJSON.version; const queryStringPrefix: string = "?"; const settings = Settings.load(); @@ -54,7 +52,7 @@ capturing and sending logs. | --- | --- | | Operating System | ${os.type()} ${os.arch()} ${os.release()} | | VSCode | ${vscode.version}| -| PowerShell Extension Version | ${extensionVersion} | +| PowerShell Extension Version | ${sessionManager.HostVersion} | ### PowerShell Information ### diff --git a/src/main.ts b/src/main.ts index e8a2825f36..44dc2c8c01 100644 --- a/src/main.ts +++ b/src/main.ts @@ -114,7 +114,9 @@ export function activate(context: vscode.ExtensionContext): void { sessionManager = new SessionManager( requiredEditorServicesVersion, - logger, documentSelector); + logger, + documentSelector, + context); // Create features extensionFeatures = [ @@ -152,10 +154,13 @@ function checkForUpdatedVersion(context: vscode.ExtensionContext) { const showReleaseNotes = "Show Release Notes"; const powerShellExtensionVersionKey = "powerShellExtensionVersion"; + const extensionName = context.storagePath.toLowerCase().includes("ms-vscode.powershell-preview") ? + "ms-vscode.PowerShell-Preview" : "ms-vscode.PowerShell"; + const extensionVersion: string = vscode .extensions - .getExtension("ms-vscode.PowerShell") + .getExtension(extensionName) .packageJSON .version; diff --git a/src/session.ts b/src/session.ts index daf47bdb20..95ab36fb97 100644 --- a/src/session.ts +++ b/src/session.ts @@ -36,10 +36,9 @@ export enum SessionStatus { } export class SessionManager implements Middleware { + public HostVersion: string; private ShowSessionMenuCommandName = "PowerShell.ShowSessionMenu"; - - private hostVersion: string; private editorServicesArgs: string; private powerShellExePath: string = ""; private sessionStatus: SessionStatus = SessionStatus.NeverStarted; @@ -66,15 +65,18 @@ export class SessionManager implements Middleware { constructor( private requiredEditorServicesVersion: string, private log: Logger, - private documentSelector: DocumentSelector) { + private documentSelector: DocumentSelector, + private context: vscode.ExtensionContext) { this.platformDetails = getPlatformDetails(); + const extensionName = context.storagePath.toLowerCase().includes("ms-vscode.powershell-preview") ? + "ms-vscode.PowerShell-Preview" : "ms-vscode.PowerShell"; // Get the current version of this extension - this.hostVersion = + this.HostVersion = vscode .extensions - .getExtension("ms-vscode.PowerShell") + .getExtension(extensionName) .packageJSON .version; @@ -83,13 +85,13 @@ export class SessionManager implements Middleware { this.log.write( `Visual Studio Code v${vscode.version} ${procBitness}`, - `PowerShell Extension v${this.hostVersion}`, + `PowerShell Extension v${this.HostVersion}`, `Operating System: ${OperatingSystem[this.platformDetails.operatingSystem]} ${osBitness}`); // Fix the host version so that PowerShell can consume it. // This is needed when the extension uses a prerelease // version string like 0.9.1-insiders-1234. - this.hostVersion = this.hostVersion.split("-")[0]; + this.HostVersion = this.HostVersion.split("-")[0]; this.registerCommands(); } @@ -169,7 +171,7 @@ export class SessionManager implements Middleware { this.editorServicesArgs = `-HostName 'Visual Studio Code Host' ` + `-HostProfileId 'Microsoft.VSCode' ` + - `-HostVersion '${this.hostVersion}' ` + + `-HostVersion '${this.HostVersion}' ` + `-AdditionalModules @('PowerShellEditorServices.VSCode') ` + `-BundledModulesPath '${PowerShellProcess.escapeSingleQuotes(this.bundledModulesPath)}' ` + `-EnableConsoleRepl `; diff --git a/tools/releaseBuild/Image/build.ps1 b/tools/releaseBuild/Image/build.ps1 index eb778b1ebf..df4c10b23b 100644 --- a/tools/releaseBuild/Image/build.ps1 +++ b/tools/releaseBuild/Image/build.ps1 @@ -9,5 +9,5 @@ else { } } push-location C:/vscode-powershell -Invoke-Build GetExtensionVersion,Clean,Build,Test,Package +Invoke-Build GetExtensionData,Clean,Build,Test,CheckPreview,Package Copy-Item -Verbose -Recurse "C:/vscode-powershell/PowerShell-insiders.vsix" "${target}/PowerShell-insiders.vsix" diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index ed913d8946..9252e315e5 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -13,8 +13,9 @@ $script:IsPullRequestBuild = $env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_REPO_BRANCH -eq "develop" -task GetExtensionVersion -Before Package { +task GetExtensionData -Before Package { + $script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json $updateVersion = $false $script:ExtensionVersion = ` if ($env:AppVeyor) { @@ -26,14 +27,15 @@ task GetExtensionVersion -Before Package { $env:VSTS_BUILD_VERSION } else { - exec { & npm version | ConvertFrom-Json | ForEach-Object { $_.PowerShell } } + $script:PackageJson.version } - Write-Host "`n### Extension Version: $script:ExtensionVersion`n" -ForegroundColor Green - if ($updateVersion) { exec { & npm version $script:ExtensionVersion --no-git-tag-version --allow-same-version } } + + $script:ExtensionName = $script:PackageJson.name + Write-Host "`n### Extension Version: $script:ExtensionVersion Extension Name: $script:ExtensionName`n" -ForegroundColor Green } task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices, Package { @@ -109,6 +111,30 @@ task Test Build, { } } +task CheckPreview -If { $script:ExtensionVersion -like "*preview*" } ` + UpdateReadme, UpdatePackageJson + +task UpdateReadme { + $newReadmeTop = '# PowerShell Language Support for Visual Studio Code + +> ## ATTENTION: This is the PREVIEW version of the PowerShell extension for VSCode which contains features that are being evaluated for stable +> ### If you are looking for the stable version, please [go here](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell) or install the extension called "PowerShell" (not "PowerShell Preview") +> ## NOTE: If you have both stable (aka "PowerShell") and preview (aka "PowerShell Preview") installed, you MUST [DISABLE](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) one of them for the best performance. Docs on how to disable an extension can be found [here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension)' + $readmePath = (Join-Path $PSScriptRoot README.md) + + $readmeContent = Get-Content -Path $readmePath + $readmeContent[0] = $newReadmeTop + $readmeContent > $readmePath +} + +task UpdatePackageJson { + $script:PackageJson.name = "PowerShell-Preview" + $script:PackageJson.displayName = "PowerShell Preview" + $script:PackageJson.description = "(Preview) Develop PowerShell scripts in Visual Studio Code!" + $script:ExtensionName = $script:PackageJson.name + Set-Content -Path $PSScriptRoot/package.json ($script:PackageJson | ConvertTo-Json -Depth 100) +} + task Package { if ($script:psesBuildScriptPath) { @@ -126,7 +152,7 @@ task Package { exec { & node ./node_modules/vsce/out/vsce package } # Change the package to have a static name for automation purposes - Move-Item -Force .\PowerShell-$($script:ExtensionVersion).vsix .\PowerShell-insiders.vsix + Move-Item -Force .\$($script:ExtensionName)-$($script:ExtensionVersion).vsix .\PowerShell-insiders.vsix } task UploadArtifacts -If { $env:AppVeyor } { @@ -134,4 +160,4 @@ task UploadArtifacts -If { $env:AppVeyor } { } # The default task is to run the entire CI build -task . GetExtensionVersion, CleanAll, BuildAll, Test, Package, UploadArtifacts +task . GetExtensionData, CleanAll, BuildAll, Test, CheckPreview, Package, UploadArtifacts From f23aa3c6498fc6c239f3923d985cfc360f2b957d Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 22 Jan 2019 10:15:22 -0800 Subject: [PATCH 2/2] add warning dialog and only write to README once --- src/main.ts | 6 ++++++ vscode-powershell.build.ps1 | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 44dc2c8c01..1ab5bcb920 100644 --- a/src/main.ts +++ b/src/main.ts @@ -157,6 +157,12 @@ function checkForUpdatedVersion(context: vscode.ExtensionContext) { const extensionName = context.storagePath.toLowerCase().includes("ms-vscode.powershell-preview") ? "ms-vscode.PowerShell-Preview" : "ms-vscode.PowerShell"; + if (extensionName === "ms-vscode.PowerShell-Preview" + && vscode.extensions.getExtension("ms-vscode.PowerShell")) { + vscode.window.showWarningMessage( + "'PowerShell' and 'PowerShell Preview' are both enabled. Please disable one for best performance."); + } + const extensionVersion: string = vscode .extensions diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index 9252e315e5..412d6ac759 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -117,14 +117,16 @@ task CheckPreview -If { $script:ExtensionVersion -like "*preview*" } ` task UpdateReadme { $newReadmeTop = '# PowerShell Language Support for Visual Studio Code -> ## ATTENTION: This is the PREVIEW version of the PowerShell extension for VSCode which contains features that are being evaluated for stable +> ## ATTENTION: This is the PREVIEW version of the PowerShell extension for VSCode which contains features that are being evaluated for stable. It works with PowerShell 5.1 and up. > ### If you are looking for the stable version, please [go here](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell) or install the extension called "PowerShell" (not "PowerShell Preview") > ## NOTE: If you have both stable (aka "PowerShell") and preview (aka "PowerShell Preview") installed, you MUST [DISABLE](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) one of them for the best performance. Docs on how to disable an extension can be found [here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension)' $readmePath = (Join-Path $PSScriptRoot README.md) $readmeContent = Get-Content -Path $readmePath - $readmeContent[0] = $newReadmeTop - $readmeContent > $readmePath + if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) { + $readmeContent[0] = $newReadmeTop + $readmeContent > $readmePath + } } task UpdatePackageJson {