|
| 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 | + |
| 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. |
0 commit comments