diff --git a/.vscode/launch.json b/.vscode/launch.json
index edcc4eff01..c780d1a25e 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -10,7 +10,7 @@
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "${workspaceRoot}/out",
- "preLaunchTask": "compile"
+ "preLaunchTask": "Build"
},
{
"name": "Attach",
diff --git a/.vscode/settings.json b/.vscode/settings.json
index e16db48f31..d5266bbbbc 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,12 +1,7 @@
// Place your settings in this file to overwrite default and user settings.
{
- // Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened.
- "editor.tabSize": 4,
-
- // Controls if the editor will insert spaces for tabs. Accepted values: "auto", true, false. If set to "auto", the value will be guessed when a file is opened.
- "editor.insertSpaces": true,
-
- // When enabled, will trim trailing whitespace when you save a file.
+ "editor.tabSize": 4,
+ "editor.insertSpaces": true,
"files.trimTrailingWhitespace": true,
// Lock the TypeScript SDK path to the version we use
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index cfaf95a718..6b29861d75 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -1,55 +1,38 @@
-// Available variables which can be used inside of strings.
-// ${workspaceRoot}: the root folder of the team
-// ${file}: the current opened file
-// ${fileBasename}: the current opened file's basename
-// ${fileDirname}: the current opened file's dirname
-// ${fileExtname}: the current opened file's extension
-// ${cwd}: the current working directory of the spawned process
-
-// A task runner that calls a custom npm script that compiles the extension.
{
- "version": "0.1.0",
-
- // we want to run npm
- "command": "npm",
-
- // the command is a shell script
- "isShellCommand": true,
+ "version": "0.1.0",
+
+ "windows": {
+ "command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
+ "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ]
+ },
+ "linux": {
+ "command": "/usr/bin/powershell",
+ "args": [ "-NoProfile" ]
+ },
+ "osx": {
+ "command": "/usr/local/bin/powershell",
+ "args": [ "-NoProfile" ]
+ },
+
+ "isShellCommand": true,
+ "showOutput": "always",
"tasks": [
{
- "taskName": "install",
- "showOutput": "always"
+ "taskName": "Install",
+ "suppressTaskName": true,
+ "args": [ "Invoke-Build Restore" ]
},
{
- "taskName": "compile",
- "isBuildCommand": true,
+ "taskName": "Clean",
"suppressTaskName": true,
-
- // show the output window only if unrecognized errors occur.
- "showOutput": "silent",
-
- // we run the custom script "compile" as defined in package.json
- "args": ["run", "compile"],
-
- // use the standard tsc problem matcher to find compile problems in the output.
- "problemMatcher": "$tsc"
+ "args": [ "Invoke-Build Clean" ]
},
{
- "taskName": "compile-watch",
+ "taskName": "Build",
"suppressTaskName": true,
-
- // show the output window only if unrecognized errors occur.
- "showOutput": "silent",
-
- // we run the custom script "compile-watch" as defined in package.json
- "args": ["run", "compile-watch"],
-
- // The tsc compiler is started in watching mode
- "isWatching": true,
-
- // use the standard tsc in watch mode problem matcher to find compile problems in the output.
- "problemMatcher": "$tsc-watch"
+ "isBuildCommand": true,
+ "args": [ "Invoke-Build Build" ]
}
]
}
diff --git a/.vscodeignore b/.vscodeignore
index cf28595d9c..54e9c77ead 100644
--- a/.vscodeignore
+++ b/.vscodeignore
@@ -1,4 +1,5 @@
.vscode/**
+vscode-powershell.build.ps1
typings/**
**/*.ts
.gitignore
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000000..5ce071f2dd
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,22 @@
+version: '0.9.0.{build}'
+image: Visual Studio 2017 RC
+clone_depth: 10
+skip_tags: true
+
+branches:
+ only:
+ - master
+ - develop
+
+install:
+ - git clone https://github.com/PowerShell/PowerShellEditorServices.git ../PowerShellEditorServices
+ - ps: Install-Product node '6.9.2'
+ - ps: |
+ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
+ Install-Module InvokeBuild -RequiredVersion 3.2.1 -Scope CurrentUser -Force | Out-Null
+
+build_script:
+ - ps: Invoke-Build Build
+
+# The build script takes care of the tests
+test: off
diff --git a/docs/development.md b/docs/development.md
index 65d4fb76e4..37f374dbf3 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -1,52 +1,43 @@
-# Working with the PowerShell extension code
+# Development Instructions for the PowerShell Extension
-## Building the code
+## Development Setup
-1. Install [Node.js](https://nodejs.org/en/) 4.4.1 or higher.
+You'll need to clone two repositories and set up your development environment
+to before you can proceed.
-2. Install the package dependencies by running one of the following commands:
+### 1. [Fork and clone](https://help.github.com/articles/fork-a-repo/) the [vscode-powershell repository](https://github.com/PowerShell/vscode-powershell)
- ```
- # From a PowerShell prompt
- npm install
+### 2. [Fork and clone](https://help.github.com/articles/fork-a-repo/) the [PowerShell Editor Services repository](https://github.com/PowerShell/PowerShellEditorServices)
- # Or from Visual Studio Code
- Press Ctrl+P and type "task install"
- ```
+### 3. Follow the [development instructions](https://github.com/PowerShell/PowerShellEditorServices#development) for PowerShell Editor Services
-3. Compile the code by running one of the following commands:
+### 4. Install [Visual Studio Code Insiders Release](https://code.visualstudio.com/insiders)
- ```
- # From a PowerShell prompt
- npm run compile
+### 5. Install [Node.js](https://nodejs.org/en/) 6.0.0 or higher.
- # Or from Visual Studio Code
- Press Ctrl+P and type "task compile"
- ```
- This will compile the TypeScript files in the project to JavaScript files.
+## Building the Code
- OR
+#### From Visual Studio Code:
- You can compile the files and then have the TypeScript compiler watch for changes to
- the source files and automatically recompile those files when changes are saved.
- To do this, run one of the following commands:
+Press Ctrl+P and type `task build`
- ```
- # From a PowerShell prompt
- npm run compile-watch
+This will compile the TypeScript files in the project to JavaScript files.
- # Or from Visual Studio Code
- Press Ctrl+P and type "task compile-watch"
- ```
+#### From a command prompt:
-## Running the compiled code
+```
+Invoke-Build Build
+```
-1. From a PowerShell prompt, run the following command:
+## Launching the extension
- ```
- code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
- ```
+#### From Visual Studio Code:
-2. If you allow the compiler to continue watching for file changes, you can use
- the `Reload Window` command found in the command palette `(Ctrl+Shift+P)`
- so that the new source files are loaded.
+To debug the extension, press F5. To run the extension without debugging,
+press Ctrl+F5 or Cmd+F5 on macOS.
+
+#### From a command prompt:
+
+```
+code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
+```
diff --git a/package.json b/package.json
index 67e52a6c1c..f076e9cf61 100644
--- a/package.json
+++ b/package.json
@@ -323,7 +323,6 @@
},
"powershell.developer.bundledModulesPath": {
"type": "string",
- "default": "../modules/",
"description": "Specifies the path to the folder containing modules that are bundled with the PowerShell extension (i.e. PowerShell Editor Services, PowerShell Script Analyzer, Plaster)"
},
"powershell.developer.editorServicesLogLevel": {
diff --git a/src/session.ts b/src/session.ts
index 179afd0d20..462ed57d77 100644
--- a/src/session.ts
+++ b/src/session.ts
@@ -72,6 +72,12 @@ export class SessionManager {
private languageServerClient: LanguageClient = undefined;
private sessionSettings: Settings.ISettings = undefined;
+ // When in development mode, VS Code's session ID is a fake
+ // value of "someValue.machineId". Use that to detect dev
+ // mode for now until Microsoft/vscode#10272 gets implemented.
+ private readonly inDevelopmentMode =
+ vscode.env.sessionId === "someValue.sessionId";
+
constructor(
private requiredEditorServicesVersion: string,
private log: Logger,
@@ -100,9 +106,24 @@ export class SessionManager {
if (this.sessionConfiguration.type === SessionType.UsePath ||
this.sessionConfiguration.type === SessionType.UseBuiltIn) {
- var bundledModulesPath = this.sessionSettings.developer.bundledModulesPath;
- if (!path.isAbsolute(bundledModulesPath)) {
- bundledModulesPath = path.resolve(__dirname, bundledModulesPath);
+ var bundledModulesPath = path.resolve(__dirname, "../modules");
+
+ if (this.inDevelopmentMode) {
+ var devBundledModulesPath =
+ // this.sessionSettings.developer.bundledModulesPath ||
+ path.resolve(
+ __dirname,
+ this.sessionSettings.developer.bundledModulesPath ||
+ "../../PowerShellEditorServices/module");
+
+ // Make sure the module's bin path exists
+ if (fs.existsSync(path.join(devBundledModulesPath, "PowerShellEditorServices/bin"))) {
+ bundledModulesPath = devBundledModulesPath;
+ }
+ else {
+ this.log.write(
+ `\nWARNING: In development mode but PowerShellEditorServices dev module path cannot be found (or has not been built yet): ${devBundledModulesPath}\n`);
+ }
}
var startArgs =
diff --git a/src/settings.ts b/src/settings.ts
index 5bf3159d8d..382f8d9351 100644
--- a/src/settings.ts
+++ b/src/settings.ts
@@ -42,7 +42,7 @@ export function load(myPluginId: string): ISettings {
let defaultDeveloperSettings: IDeveloperSettings = {
powerShellExePath: undefined,
- bundledModulesPath: "../modules/",
+ bundledModulesPath: undefined,
editorServicesLogLevel: "Normal",
editorServicesWaitForDebugger: false,
powerShellExeIsWindowsDevBuild: false
diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1
new file mode 100644
index 0000000000..5f815f6318
--- /dev/null
+++ b/vscode-powershell.build.ps1
@@ -0,0 +1,63 @@
+#
+# Copyright (c) Microsoft. All rights reserved.
+# Licensed under the MIT license. See LICENSE file in the project root for full license information.
+#
+
+param(
+ [string]$EditorServicesRepoPath = $null
+)
+
+#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}
+
+task ResolveEditorServicesPath -Before Clean, Build {
+ $script:psesRepoPath = `
+ if ($EditorServicesRepoPath) {
+ $EditorServicesRepoPath
+ }
+ else {
+ "$PSScriptRoot/../PowerShellEditorServices/"
+ }
+
+ if (!(Test-Path $script:psesRepoPath)) {
+ # Clear the path so that it won't be used
+ Write-Host "`n### WARNING: The PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n" -ForegroundColor Yellow
+ $script:psesRepoPath = $null
+ }
+ else {
+ $script:psesRepoPath = Resolve-Path $script:psesRepoPath
+ $script:psesBuildScriptPath = Resolve-Path "$script:psesRepoPath/PowerShellEditorServices.build.ps1"
+ }
+}
+
+task Restore -If { "Restore" -in $BuildTask -or !(Test-Path "./node_modules") } -Before Build {
+ Write-Host "`n### Restoring vscode-powershell dependencies`n" -ForegroundColor Green
+
+ # When in a CI build use the --loglevel=error parameter so that
+ # package install warnings don't cause PowerShell to throw up
+ $logLevelParam = if ($env:AppVeyor) { "--loglevel=error" } else { "" }
+ exec { & npm install $logLevelParam }
+}
+
+task Clean {
+ if ($script:psesBuildScriptPath) {
+ Write-Host "`n### Cleaning PowerShellEditorServices`n" -ForegroundColor Green
+ Invoke-Build Clean $script:psesBuildScriptPath
+ }
+
+ Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
+ Remove-Item .\out -Recurse -Force -ErrorAction Ignore
+}
+
+task Build {
+
+ # If the PSES codebase is co-located, build it first
+ if ($script:psesBuildScriptPath) {
+ Write-Host "`n### Building PowerShellEditorServices`n" -ForegroundColor Green
+ Invoke-Build BuildHost $script:psesBuildScriptPath
+ }
+
+ Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
+ exec { & npm run compile }
+}
+
+task . Clean, Build