Skip to content

Commit 12c3510

Browse files
Support Preview mechanism (#1707)
* upport Preview mechanism * add warning dialog and only write to README once
1 parent ff6f494 commit 12c3510

File tree

9 files changed

+94
-21
lines changed

9 files changed

+94
-21
lines changed

.github/ISSUE_TEMPLATE/Bug_report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ IMPORTANT: you can generate a bug report directly from the
1313
PowerShell extension in Visual Studio Code by selecting
1414
"PowerShell: Upload Bug Report to GitHub" from the command palette.
1515
16+
NOTE: If you have both stable (aka "PowerShell") and preview (aka "PowerShell Preview") installed,
17+
you MUST DISABLE one of them for the best performance.
18+
Docs on how to disable an extension can be found here:
19+
https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension
20+
1621
The more repro details you can provide, along with a zip
1722
of the log files from your session, the better the chances
1823
are for a quick resolution.

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,14 @@ how to use them.
8888

8989
This folder can be found at the following path:
9090

91+
```powershell
92+
$HOME/.vscode[-insiders]/extensions/ms-vscode.PowerShell-<version>/examples
9193
```
92-
C:\Users\<yourusername>\.vscode\extensions\ms-vscode.PowerShell-<version>\examples
94+
95+
or if you're using the preview version of the extension
96+
97+
```powershell
98+
$HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-preview-<version>/examples
9399
```
94100

95101
To open/view the extension's examples in Visual Studio Code, run the following from your PowerShell command prompt:

docs/development.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ press <kbd>Ctrl</kbd>+<kbd>F5</kbd> or <kbd>Cmd</kbd>+<kbd>F5</kbd> on macOS.
4444
```
4545
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
4646
```
47+
48+
## Building a "Preview" version
49+
50+
To build a preview version of the extension, that is to say,
51+
a version of the extension named "PowerShell Preview",
52+
You can simply change the version in the package.json to include `-preview` at the end.
53+
When you build, this will:
54+
55+
- 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
56+
- Adds "Preview" in a few places in the package.json
57+
58+
This mechanism is mostly used for releases.

docs/troubleshooting.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ and you can ask for new features [in their repository](https://github.com/Micros
3434

3535
## Known Issues in the Extension
3636

37+
- If you are running the Preview version "PowerShell Preview" side-by-side with the stable version "PowerShell"
38+
you will experience performance and debug issues.
39+
This is expected until VSCode offers extension channels - [vscode#15756](https://github.com/Microsoft/vscode/issues/15756)
40+
- You MUST [DISABLE](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) one of them for the best performance.
41+
Docs on how to disable an extension can be found [here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension)
3742
- Highlighting/completions/command history don't work as I expect in the
3843
Integrated Console - [#535]
3944
- The Integrated Console implements a [custom host]
@@ -157,6 +162,12 @@ Logs provide context for what was happening when the issue occurred
157162
$HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-<version>/logs/
158163
```
159164

165+
or if you're using the preview version of the extension
166+
167+
```powershell
168+
$HOME/.vscode[-insiders]/extensions/ms-vscode.powershell-preview-<version>/logs/
169+
```
170+
160171
For example:
161172

162173
```powershell

src/features/GenerateBugReport.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { IFeature, LanguageClient } from "../feature";
99
import { SessionManager } from "../session";
1010
import Settings = require("../settings");
1111

12-
const extensionId: string = "ms-vscode.PowerShell";
13-
const extensionVersion: string = vscode.extensions.getExtension(extensionId).packageJSON.version;
1412
const queryStringPrefix: string = "?";
1513

1614
const settings = Settings.load();
@@ -54,7 +52,7 @@ capturing and sending logs.
5452
| --- | --- |
5553
| Operating System | ${os.type()} ${os.arch()} ${os.release()} |
5654
| VSCode | ${vscode.version}|
57-
| PowerShell Extension Version | ${extensionVersion} |
55+
| PowerShell Extension Version | ${sessionManager.HostVersion} |
5856
5957
### PowerShell Information ###
6058

src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ export function activate(context: vscode.ExtensionContext): void {
114114
sessionManager =
115115
new SessionManager(
116116
requiredEditorServicesVersion,
117-
logger, documentSelector);
117+
logger,
118+
documentSelector,
119+
context);
118120

119121
// Create features
120122
extensionFeatures = [
@@ -152,10 +154,19 @@ function checkForUpdatedVersion(context: vscode.ExtensionContext) {
152154
const showReleaseNotes = "Show Release Notes";
153155
const powerShellExtensionVersionKey = "powerShellExtensionVersion";
154156

157+
const extensionName = context.storagePath.toLowerCase().includes("ms-vscode.powershell-preview") ?
158+
"ms-vscode.PowerShell-Preview" : "ms-vscode.PowerShell";
159+
160+
if (extensionName === "ms-vscode.PowerShell-Preview"
161+
&& vscode.extensions.getExtension("ms-vscode.PowerShell")) {
162+
vscode.window.showWarningMessage(
163+
"'PowerShell' and 'PowerShell Preview' are both enabled. Please disable one for best performance.");
164+
}
165+
155166
const extensionVersion: string =
156167
vscode
157168
.extensions
158-
.getExtension("ms-vscode.PowerShell")
169+
.getExtension(extensionName)
159170
.packageJSON
160171
.version;
161172

src/session.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ export enum SessionStatus {
3636
}
3737

3838
export class SessionManager implements Middleware {
39+
public HostVersion: string;
3940

4041
private ShowSessionMenuCommandName = "PowerShell.ShowSessionMenu";
41-
42-
private hostVersion: string;
4342
private editorServicesArgs: string;
4443
private powerShellExePath: string = "";
4544
private sessionStatus: SessionStatus = SessionStatus.NeverStarted;
@@ -66,15 +65,18 @@ export class SessionManager implements Middleware {
6665
constructor(
6766
private requiredEditorServicesVersion: string,
6867
private log: Logger,
69-
private documentSelector: DocumentSelector) {
68+
private documentSelector: DocumentSelector,
69+
private context: vscode.ExtensionContext) {
7070

7171
this.platformDetails = getPlatformDetails();
72+
const extensionName = context.storagePath.toLowerCase().includes("ms-vscode.powershell-preview") ?
73+
"ms-vscode.PowerShell-Preview" : "ms-vscode.PowerShell";
7274

7375
// Get the current version of this extension
74-
this.hostVersion =
76+
this.HostVersion =
7577
vscode
7678
.extensions
77-
.getExtension("ms-vscode.PowerShell")
79+
.getExtension(extensionName)
7880
.packageJSON
7981
.version;
8082

@@ -83,13 +85,13 @@ export class SessionManager implements Middleware {
8385

8486
this.log.write(
8587
`Visual Studio Code v${vscode.version} ${procBitness}`,
86-
`PowerShell Extension v${this.hostVersion}`,
88+
`PowerShell Extension v${this.HostVersion}`,
8789
`Operating System: ${OperatingSystem[this.platformDetails.operatingSystem]} ${osBitness}`);
8890

8991
// Fix the host version so that PowerShell can consume it.
9092
// This is needed when the extension uses a prerelease
9193
// version string like 0.9.1-insiders-1234.
92-
this.hostVersion = this.hostVersion.split("-")[0];
94+
this.HostVersion = this.HostVersion.split("-")[0];
9395

9496
this.registerCommands();
9597
}
@@ -169,7 +171,7 @@ export class SessionManager implements Middleware {
169171
this.editorServicesArgs =
170172
`-HostName 'Visual Studio Code Host' ` +
171173
`-HostProfileId 'Microsoft.VSCode' ` +
172-
`-HostVersion '${this.hostVersion}' ` +
174+
`-HostVersion '${this.HostVersion}' ` +
173175
`-AdditionalModules @('PowerShellEditorServices.VSCode') ` +
174176
`-BundledModulesPath '${PowerShellProcess.escapeSingleQuotes(this.bundledModulesPath)}' ` +
175177
`-EnableConsoleRepl `;

tools/releaseBuild/Image/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ else {
99
}
1010
}
1111
push-location C:/vscode-powershell
12-
Invoke-Build GetExtensionVersion,Clean,Build,Test,Package
12+
Invoke-Build GetExtensionData,Clean,Build,Test,CheckPreview,Package
1313
Copy-Item -Verbose -Recurse "C:/vscode-powershell/PowerShell-insiders.vsix" "${target}/PowerShell-insiders.vsix"

vscode-powershell.build.ps1

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ $script:IsPullRequestBuild =
1313
$env:APPVEYOR_PULL_REQUEST_NUMBER -and
1414
$env:APPVEYOR_REPO_BRANCH -eq "develop"
1515

16-
task GetExtensionVersion -Before Package {
16+
task GetExtensionData -Before Package {
1717

18+
$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
1819
$updateVersion = $false
1920
$script:ExtensionVersion = `
2021
if ($env:AppVeyor) {
@@ -26,14 +27,15 @@ task GetExtensionVersion -Before Package {
2627
$env:VSTS_BUILD_VERSION
2728
}
2829
else {
29-
exec { & npm version | ConvertFrom-Json | ForEach-Object { $_.PowerShell } }
30+
$script:PackageJson.version
3031
}
3132

32-
Write-Host "`n### Extension Version: $script:ExtensionVersion`n" -ForegroundColor Green
33-
3433
if ($updateVersion) {
3534
exec { & npm version $script:ExtensionVersion --no-git-tag-version --allow-same-version }
3635
}
36+
37+
$script:ExtensionName = $script:PackageJson.name
38+
Write-Host "`n### Extension Version: $script:ExtensionVersion Extension Name: $script:ExtensionName`n" -ForegroundColor Green
3739
}
3840

3941
task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices, Package {
@@ -109,6 +111,32 @@ task Test Build, {
109111
}
110112
}
111113

114+
task CheckPreview -If { $script:ExtensionVersion -like "*preview*" } `
115+
UpdateReadme, UpdatePackageJson
116+
117+
task UpdateReadme {
118+
$newReadmeTop = '# PowerShell Language Support for Visual Studio Code
119+
120+
> ## 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.
121+
> ### 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")
122+
> ## 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)'
123+
$readmePath = (Join-Path $PSScriptRoot README.md)
124+
125+
$readmeContent = Get-Content -Path $readmePath
126+
if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) {
127+
$readmeContent[0] = $newReadmeTop
128+
$readmeContent > $readmePath
129+
}
130+
}
131+
132+
task UpdatePackageJson {
133+
$script:PackageJson.name = "PowerShell-Preview"
134+
$script:PackageJson.displayName = "PowerShell Preview"
135+
$script:PackageJson.description = "(Preview) Develop PowerShell scripts in Visual Studio Code!"
136+
$script:ExtensionName = $script:PackageJson.name
137+
Set-Content -Path $PSScriptRoot/package.json ($script:PackageJson | ConvertTo-Json -Depth 100)
138+
}
139+
112140
task Package {
113141

114142
if ($script:psesBuildScriptPath) {
@@ -126,12 +154,12 @@ task Package {
126154
exec { & node ./node_modules/vsce/out/vsce package }
127155

128156
# Change the package to have a static name for automation purposes
129-
Move-Item -Force .\PowerShell-$($script:ExtensionVersion).vsix .\PowerShell-insiders.vsix
157+
Move-Item -Force .\$($script:ExtensionName)-$($script:ExtensionVersion).vsix .\PowerShell-insiders.vsix
130158
}
131159

132160
task UploadArtifacts -If { $env:AppVeyor } {
133161
Push-AppveyorArtifact .\PowerShell-insiders.vsix
134162
}
135163

136164
# The default task is to run the entire CI build
137-
task . GetExtensionVersion, CleanAll, BuildAll, Test, Package, UploadArtifacts
165+
task . GetExtensionData, CleanAll, BuildAll, Test, CheckPreview, Package, UploadArtifacts

0 commit comments

Comments
 (0)