Skip to content

Commit 98dd05b

Browse files
committed
Initial commit for 0.1.0-preview
This commit establishes the codebase for the initial release of Windows PowerShell for Visual Studio Code.
1 parent 84eb0d9 commit 98dd05b

38 files changed

+6261
-19
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bin/
2+
out/
3+
node_modules/
4+
vscode-powershell.zip
5+
vscps-preview.zip

.vscode/launch.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "0.1.0",
3+
"configurations": [
4+
{
5+
"request": "launch",
6+
"name": "Launch Extension",
7+
"type": "extensionHost",
8+
//"runtimeExecutable": "${execPath}",
9+
"runtimeExecutable": "c:/dev/Monaco/tools/code.bat",
10+
"args": [
11+
"--extensionDevelopmentPath=${workspaceRoot}",
12+
"c:/Users/daviwil/Documents/DemoFiles"
13+
],
14+
"stopOnEntry": false,
15+
"sourceMaps": true,
16+
"outDir": "out",
17+
"preLaunchTask": "npm"
18+
},
19+
{
20+
"name": "Attach",
21+
"type": "node",
22+
"address": "localhost",
23+
"port": 5858,
24+
"sourceMaps": false
25+
}
26+
]
27+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
}

.vscode/tasks.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Available variables which can be used inside of strings.
2+
// ${workspaceRoot}: the root folder of the team
3+
// ${file}: the current opened file
4+
// ${fileBasename}: the current opened file's basename
5+
// ${fileDirname}: the current opened file's dirname
6+
// ${fileExtname}: the current opened file's extension
7+
// ${cwd}: the current working directory of the spawned process
8+
9+
// A task runner that calls a custom npm script that compiles the extension.
10+
{
11+
"version": "0.1.0",
12+
13+
// we want to run npm
14+
"command": "npm",
15+
16+
// the command is a shell script
17+
"isShellCommand": true,
18+
19+
// show the output window only if unrecognized errors occur.
20+
"showOutput": "silent",
21+
22+
// we run the custom script "compile" as defined in package.json
23+
"args": ["run", "compile"],
24+
25+
// The tsc compiler is started in watching mode
26+
"isWatching": true,
27+
28+
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
29+
"problemMatcher": "$tsc-watch"
30+
}

.vscodeignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.vscode/**
2+
typings/**
3+
node_modules/vscode/**
4+
node_modules/vscode-languageworker/**
5+
**/*.ts
6+
.gitignore
7+
tsconfig.json
8+
bin/EditorServices.log
9+
bin/*.vshost.*

LICENSE

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
The MIT License (MIT)
1+
Windows PowerShell for Visual Studio Code 0.1.0
2+
Copyright (c) Microsoft Corporation
23

3-
Copyright (c) 2015 PowerShell
4+
All rights reserved.
45

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
6+
MIT License
117

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
8+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
149

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2213

README.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
1-
# VSCodePowerShell
2-
PowerShell language support for Visual Studio Code text editor
1+
# Windows PowerShell for Visual Studio Code
2+
3+
Windows PowerShell language support for Visual Studio Code.
4+
More details forthcoming.
5+
6+
## Building the code
7+
8+
`npm run compile`
9+
10+
After the initial compile, the source files will be watched and recompiled
11+
when changes are saved.
12+
13+
## Running the compiled code
14+
15+
From a PowerShell or cmd.exe prompt, run the following command:
16+
17+
`code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .`
18+
19+
If you allow the compiler to continue watching for file changes, you can use
20+
the `Reload Window` command found in the command palette `(Ctrl+Shift+P)`
21+
so that the new source files are loaded.
22+
23+
## Example Scripts
24+
25+
There are some example scripts in the `examples` folder that you can
26+
use to discover PowerShell editing and debugging functionality. Please
27+
check out the [README.md](examples/README.md) file to learn more about
28+
how to use them.
29+
30+
## License
31+
32+
This project is [licensed under the MIT License](LICENSE). Please see the
33+
[third-party notices](Third Party Notices.txt) file for details on the third-party
34+
binaries that we include with releases of this project.

Third Party Notices.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
This file is based on or incorporates material from the projects listed below (Third Party IP). The original copyright notice and the license under which Microsoft received such Third Party IP, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft licenses the Third Party IP to you under the licensing terms for the Microsoft product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
2+
3+
---
4+
5+
Json.NET
6+
7+
Copyright (c) 2007 James Newton-King
8+
Provided for Informational Purposes Only
9+
10+
MIT License
11+
12+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17+
18+
---
19+
20+
AsyncEx
21+
22+
Copyright (c) 2014 StephenCleary
23+
Provided for Informational Purposes Only
24+
25+
MIT License
26+
27+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
28+
29+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
30+
31+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

build/InstallPreview.ps1

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# Make sure VS Code isn't running first
3+
$ErrorActionPreference = "SilentlyContinue"
4+
if ((Get-Process -Name "Code").Count -gt 0)
5+
{
6+
Write-Warning "Visual Studio Code is currently running. You must close all VS Code windows before continuing."
7+
}
8+
else
9+
{
10+
# Fail fast on future errors
11+
$ErrorActionPreference = "Stop"
12+
13+
$destPath = "$env:USERPROFILE\.vscode\extensions\vscode-powershell\"
14+
15+
if (Test-Path $destPath)
16+
{
17+
Remove-Item $destPath -Recurse
18+
}
19+
20+
Write-Output "Installing to $destPath"
21+
Expand-Archive -Path ".\vscode-powershell.zip" -DestinationPath $destPath
22+
23+
if ($?)
24+
{
25+
Write-Output "Installation complete!"
26+
Write-Output ""
27+
Write-Output "Launching Visual Studio Code..."
28+
29+
& "${env:ProgramFiles(x86)}\Microsoft VS Code\Code.exe" "$destPath\examples\" "$destPath\examples\README.md" 2>&1 | Out-Null
30+
}
31+
else
32+
{
33+
Write-Output "Installation failed!"
34+
}
35+
}

build/PackagePreviewRelease.ps1

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
param([string]$EditorServicesRepoPath = "")
2+
3+
$ErrorActionPreference = "Stop"
4+
5+
# Simple test to make sure we're in the root folder
6+
if (!(Test-Path "package.json"))
7+
{
8+
throw "This script must be run from the root vscode-powershell folder (contains package.json)."
9+
}
10+
11+
if ([string]::IsNullOrEmpty($EditorServicesRepoPath) -or !(Test-Path $EditorServicesRepoPath))
12+
{
13+
throw "Must provide path to a PowerShell Editor Services Git repository"
14+
}
15+
16+
$hostBinPath = Join-Path $EditorServicesRepoPath "src\PowerShellEditorServices.Host\bin\Debug"
17+
18+
if (!(Test-Path $hostBinPath))
19+
{
20+
throw "The path '$hostBinPath' was not found. Has the Editor Services solution been compiled?"
21+
}
22+
23+
Remove-Item -Path ".\bin\*"
24+
Copy-Item -Path "$hostBinPath\*" -Include ("*.exe", "*.dll", "*.pdb", "*.xml") -Exclude ("*.vshost.exe") -Destination ".\bin"
25+
26+
$packageFiles = @(
27+
"out",
28+
"bin",
29+
#"LICENSE",
30+
"package.json",
31+
#"README.md",
32+
"Third Party Notices.txt",
33+
"snippets",
34+
"examples"
35+
)
36+
37+
# Build the extension files package
38+
Compress-Archive -DestinationPath "vscode-powershell.zip" -Path $packageFiles -Force
39+
40+
# Build the release package
41+
Compress-Archive -DestinationPath "vscps-preview.zip" -Path @(".\build\InstallPreview.ps1", "vscode-powershell.zip") -Force
42+
43+
Write-Output "Packaging complete."

examples/.vscode/launch.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.1.0",
3+
"configurations": [
4+
{
5+
"name": "PowerShell",
6+
"type": "PowerShell",
7+
"program": "DebugTest.ps1"
8+
}
9+
]
10+
}

examples/DebugTest.ps1

670 Bytes
Binary file not shown.

examples/README.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Example Files README
2+
3+
*NOTE: For a more comfortable reading experience, use the key combination `Ctrl+Shift+V`*
4+
5+
This folder contains a few basic PowerShell script files that you can use
6+
to experiment with the new PowerShell editing and debugging capabilities.
7+
Here are some ideas for what you can try with these scripts:
8+
9+
## Language Features
10+
11+
- **Integrated syntax checks** from the PowerShell engine and **integrated
12+
rule-based analysis** using PowerShell Script Analyzer
13+
- Try opening `DebugTest.ps1` and `StopTest.ps1` by double-clicking on their
14+
file names. You will see red and green squiggles for rule-based checks.
15+
You can introduce a syntax error somewhere to see the red squiggle for
16+
that as well. To see a list of all errors and warnings, try pressing
17+
`Ctrl+Shift+M`.
18+
- **Go to definition `(F12)`** and **Peek definition `(Alt+F12)`**
19+
for cmdlet and variable names
20+
- Try this on the `Stop-Process2` cmdlet in `StopTest.ps1`
21+
- **Find all references `(Shift+F12)`** for cmdlet and variable names
22+
- Also try this on the `Stop-Process2` cmdlet in `StopTest.ps1`
23+
- **Change all occurrences `(Ctrl+F2)`** for renaming symbols
24+
- Try this on the `$process` variable in `Stop-Process2.ps1`
25+
26+
## Local Script Debugging
27+
28+
You can run scripts under the debugger by going to the debug workspace
29+
`(Ctrl+Shift+D)` and clicking the `Start` button or just by pressing `F5`.
30+
By default the debugger will start the `DebugTest.ps1` script. You can
31+
set breakpoints, pause execution, look at the call stack, inspect variables,
32+
and set specific variables to be watched.
33+
34+
Try these steps:
35+
36+
1. Open the Debug workspace by pressing `Ctrl+Shift+D`
37+
2. Press `F5` to start debugging. Once the status bar turns orange, the script is running.
38+
3. Press the blue **Pause** button at the top of the screen. The debugger
39+
will stop executing wherever it is at the moment and will bring you to the
40+
file and line where it stopped.
41+
4. Check out the **Variables** pane at the top left of the window. Scroll
42+
through the list and inspect some of the variables there.
43+
5. Find the variable `i` in the Variables list, right click it and select
44+
**Add to Watch**. The variable should appear in the **Watch** pane now.
45+
6. Hover over the title of the **Watch** pane and some buttons should appear.
46+
Click the plus sign `+` button and type `str` then press enter.
47+
7. Back in the editor, click to the left of line 10 to set a breakpoint there.
48+
8. Click the green **Play** button or press `F5` to continue execution.
49+
9. Observe that every time the breakpoint is hit, the watch variables get updated.
50+
10. When you're done debugging, click the red **Stop** button or press `Shift+F5`
51+
52+
If you would like to debug a different script, you will need to edit the
53+
`.vscode\launch.json` file and change the `program` parameter to point to
54+
the script file to be debugged. In the future we hope to remove the
55+
necessity of this setting so that the current script file will be executed
56+
when `F5` is pressed.
57+
58+
## Feedback
59+
60+
We would love to hear your feedback! Please send feature requests or issue
61+
reports to [[email protected]](mailto:[email protected]) for now.
62+
We'll provide a more appropriate issue tracker soon.
63+
64+
If you are experiencing any errors or crashes, please include the
65+
following two log files:
66+
67+
- The language service log file: `$env:USERPROFILE\.vscode\extensions\vscode-powershell\bin\EditorServices.log`
68+
- The debugging service log file: `$env:USERPROFILE\.vscode\extensions\vscode-powershell\bin\DebugService.log`
69+
- NOTE: This file may not exist if you haven't use the debugger yet.

examples/Stop-Process2.ps1

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<#
2+
.Synopsis
3+
Short description
4+
.DESCRIPTION
5+
Long description
6+
.EXAMPLE
7+
Example of how to use this cmdlet
8+
.EXAMPLE
9+
Another example of how to use this cmdlet
10+
#>
11+
function Stop-Process2
12+
{
13+
[CmdletBinding(SupportsShouldProcess = $true)]
14+
[Alias()]
15+
[OutputType([int])]
16+
Param
17+
(
18+
# Param1 help description
19+
[Parameter(Mandatory=$true,
20+
ValueFromPipelineByPropertyName=$true,
21+
Position=0)]
22+
$Name
23+
)
24+
25+
Begin
26+
{
27+
}
28+
Process
29+
{
30+
if ($PSCmdlet.ShouldProcess("")) {
31+
$processes = Get-Process -Name $Name
32+
foreach ($process in $processes)
33+
{
34+
$id = $process.Id
35+
$name = $process.Name
36+
Write-Output "Killing $name ($id)"
37+
38+
$process.Kill();
39+
40+
Start-Sleep -Seconds 1
41+
}
42+
}
43+
}
44+
End
45+
{
46+
}
47+
}

0 commit comments

Comments
 (0)