Skip to content

Support Preview mechanism #1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<version>/examples
```
C:\Users\<yourusername>\.vscode\extensions\ms-vscode.PowerShell-<version>\examples

or if you're using the preview version of the extension

```powershell
$HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-preview-<version>/examples
```

To open/view the extension's examples in Visual Studio Code, run the following from your PowerShell command prompt:
Expand Down
12 changes: 12 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,15 @@ press <kbd>Ctrl</kbd>+<kbd>F5</kbd> or <kbd>Cmd</kbd>+<kbd>F5</kbd> 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.
11 changes: 11 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -157,6 +162,12 @@ Logs provide context for what was happening when the issue occurred
$HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-<version>/logs/
```

or if you're using the preview version of the extension

```powershell
$HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-preview-<version>/logs/
```

For example:

```powershell
Expand Down
4 changes: 1 addition & 3 deletions src/features/GenerateBugReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 ###

Expand Down
15 changes: 13 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export function activate(context: vscode.ExtensionContext): void {
sessionManager =
new SessionManager(
requiredEditorServicesVersion,
logger, documentSelector);
logger,
documentSelector,
context);

// Create features
extensionFeatures = [
Expand Down Expand Up @@ -152,10 +154,19 @@ 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";

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
.getExtension("ms-vscode.PowerShell")
.getExtension(extensionName)
.packageJSON
.version;

Expand Down
18 changes: 10 additions & 8 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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();
}
Expand Down Expand Up @@ -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 `;
Expand Down
2 changes: 1 addition & 1 deletion tools/releaseBuild/Image/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
40 changes: 34 additions & 6 deletions vscode-powershell.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -109,6 +111,32 @@ 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. 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
if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) {
$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) {
Expand All @@ -126,12 +154,12 @@ 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 } {
Push-AppveyorArtifact .\PowerShell-insiders.vsix
}

# 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