r/PowerShell • PowerShell ISE Code Engineer • May 10 '17

Announcing PowerShell for Visual Studio Code 1.0!

https://blogs.msdn.microsoft.com/powershell/2017/05/10/announcing-powershell-for-visual-studio-code-1-0/
126 Upvotes

23 comments sorted by

18

u/daviwil PowerShell ISE Code Engineer May 10 '17

Changelog for this release:

We are excited to announce that we've reached version 1.0! For more information, please see the official announcement on the PowerShell Team Blog.

New script argument UI when debugging (#705)

You can now set PowerShell debugger configurations to prompt for arguments to be passed to your script when it is executed. This is configured using the new ${command:SpecifyScriptArgs} configuration variable in launch.json:

        {
            "type": "PowerShell",
            "request": "launch",
            "name": "PowerShell Launch DebugTest.ps1 w/Args Prompt",
            "script": "${workspaceRoot}/DebugTest.ps1",
            "args": [ "${command:SpecifyScriptArgs}" ],
            "cwd": "${file}"
        }

When you launch this configuration you will see a UI popup asking for arguments:

image

You can type your arguments to the script as you would in PowerShell:

-Count 5

In future executions of this configuration, you will be presented with the arguments you typed the last time you ran it so that you can easily edit them and test variations!

New hash table alignment formatting rule (#672)

We've added a new code formatting rule that automatically aligns the equal sign in assignments of keys in hash tables or DSC configurations. It also works with nested hash tables! Here's a simple example:

Before

$formatTest = @{
    Apple = 4
    Tangerine = @{
        Orange = 2
        CornflowerBlue = 6
    }
    Banana = 3
}

After


$formatTest = @{
    Apple     = 4
    Tangerine = @{
        Orange         = 2
        CornflowerBlue = 6
    }
    Banana    = 3
}

This formatting rule is enabled by default but can be disabled with the following setting:

"powershell.codeFormatting.alignPropertyValuePairs": false

Added basic module-wide function references support

In the past, finding the references or definition of a function in FileA.ps1 only worked if FileA.ps1 had an explicit dot-source invocation of FileB.ps1. We have removed this limitation so that you can now find definitions and references of any function across all the script files in your project folder! This is especially useful if you write PowerShell modules where all of the source files are dot-sourced inside of the .psm1 file.

This new implementation is very basic and may give unexpected results, so please file an issue on GitHub if you get a result you did not expect!

Other integrated console and debugger improvements

  • Fixed #698 - When debugging scripts in the integrated console, the cursor position should now be stable after stepping through your code! Please let us know if you see any other cases where this issue appears.

  • Fixed #626 - Fixed an issue where debugging a script in one VS Code window would cause that script's output to be written to a different VS Code window in the same process.

  • Fixed #618 - Pressing enter on an empty command line in the Integrated Console no longer adds the empty line to the command history.

  • Fixed #617 - Stopping the debugger during a prompt for a mandatory script parameter no longer crashes the language server.

  • Fixed PowerShellEditorServices #428 - Debugger no longer hangs when you stop debugging while an input or choice prompt is active in the integrated console.

1

u/Thirdbeat May 10 '17

Awesome stuff! Just one question: Any plans of also making the function search track changes too? As in : I change a function name, and it asks if you want to change the the occurences where this function has been named too?

4

u/daviwil PowerShell ISE Code Engineer May 10 '17

You mean renaming a function across all files in the workspace? Yep, I need to get that wired up, shouldn't take much effort now though. Filed this issue to track it:

https://github.com/PowerShell/vscode-powershell/issues/727

0

u/[deleted] May 11 '17

[deleted]

1

u/daviwil PowerShell ISE Code Engineer May 11 '17

Thank you! I'm not sure what happened to the post this time, I've pasted Markdown in the past before an it worked fine.

7

u/halbaradkenafin May 10 '17

Awesome work David. I'm loving VS Code with this extension for powershell dev. I'm slowly introducing more and more people to it and dragging them away from ISE and it's quirks.

3

u/daviwil PowerShell ISE Code Engineer May 10 '17

Awesome, glad to hear it! Thanks for spreading the word :)

2

u/Stoffel_1982 May 10 '17

Thanks. I really love how all of this is evolving.

2

u/daviwil PowerShell ISE Code Engineer May 10 '17

Thanks a lot!

1

u/[deleted] May 10 '17

David, was the enter-pssession bug fixed in this release by chance?

2

u/daviwil PowerShell ISE Code Engineer May 10 '17

This one?

https://github.com/PowerShell/vscode-powershell/issues/691

Not yet, I'll look into it for the next patch update!

1

u/[deleted] May 10 '17

That be the one, thanks David!

1

u/TheShadowhawk May 11 '17

Your dedication and work on this plugin is incredible! Keep up the great work Dave!

Now I hear that the PS ISE is now going to be secondary to VS code moving forward with regards to PowerShell development?

Good stuff!

1

u/daviwil PowerShell ISE Code Engineer May 11 '17

Thanks a lot! ISE will continue to exist, but VS Code will be the focus of our efforts.

1

u/KazuyaDarklight May 11 '17

Dumb question; I have VS Community, obviously, I could get VS Code too but that seems like it would be redundant. Is there a way to get this on Community too? Do I not understand Code's niche? It always seems to read like a stripped down/streamlined version of VS for those who don't need/want quite so many bells and whistles.

2

u/daviwil PowerShell ISE Code Engineer May 11 '17

If you prefer Visual Studio, I'd recommend using Adam Driscoll's PoshTools for Visual Studio extension:

https://marketplace.visualstudio.com/items?itemName=AdamRDriscoll.PowerShellToolsforVisualStudio2017-18561

1

u/KazuyaDarklight May 11 '17

I'm not sure I'd say I really prefer anything yet, I'm not a strong coder but I'm to get into it so I went with VS Community because I figured I could use all the software tool help I could get. For more or less the same reason that is also why I am legitimately asking if I misinterpreted codes place at all, maybe I should have both of them.

1

u/daviwil PowerShell ISE Code Engineer May 12 '17

I like VS Code because it gives you much of the same power as Visual Studio while staying out of your way. VS just feels to bloated and UI-heavy to me. VS Code lets me focus on the code itself and then have access to all the other IDE-like benefits whenever I want them. I highly recommend it!

2

u/mellman99 May 10 '17

I didn't know I needed this in my life until I stumbled on this... I hate ISE thank you!

1

u/mycall May 11 '17

I can't wait until VSCode comes with Windows Server and Client OS to replace notepad.

1

u/TheShadowhawk May 11 '17

Yaassss! Notepad needs to die! long live VS Code!

0

u/[deleted] May 11 '17

[deleted]

3

u/daviwil PowerShell ISE Code Engineer May 11 '17

Try Ctrl+Shift+O, it gives you a navigable list of all the functions in the current file :)

3

u/halbaradkenafin May 11 '17

Check out https://youtu.be/Y3aALvpNZrk where David goes into module development in vs code and some of the cool keyboard shortcuts you can use, including one for just what you want.

1

u/daviwil PowerShell ISE Code Engineer May 11 '17

Thanks for the assist!