Reputation: 320
I've been working on a Powershell script that was handed to me. Never having dealt with powershell scritps before, I have a lot to learn. I have been using Visual Studio Code to run/debug it up until this point. It has been working well however, I'm running into an issue in a particular area that deals with multiple threads. I am unable to pause the Powershell script on specific breakpoints.
After looking all over the past couple of days and it seems that threading is something that can be worked on within Visual Studio. I downloaded Visual Studio Community 2019 and have tried to install the "Powershell Tools for Visual Studio" suite. According to the package manager, it has installed without issue. However, I am unable to create a Powershell project (which I should be able to do) and I cannot see it within the extension manager in Visual Studio 2019. To make sure it wasn't an error on my part, I've attempted the installation several different times and with different methods.
I've also looked at Windows built-in Powershell ISE for debugging but run into the same issue that Visual Studio Code has. This is rendering me unable to properly debug in the specific spots that I need to looking at. I have used Write-Host
throughout most of the script however, as this is a script that was handed to me, I'd much rather be able to pause and look at all variables in a given state without having to print them all.
Is there any way to easily debug multi-threaded apps within Visual Studio Code? If there isn't, what would be some recommendations besides adding Write-Host
,Write-Debug
or similar cmdlets.
Upvotes: 5
Views: 10039
Reputation: 1
I've decided the answer to this is no...
It should be as easy as put the breakpoint, hit the breakpoint, until ms supports this, its way behind any other decent scripting language. I'm thinking to unthread my application to make my life easier which is pretty sad state of affairs. Might try spinning up full visual studio to see if its better first.
Upvotes: 0
Reputation: 391
I know this is relatively old, but it is worth noting if this shows in future search results. What VSCode can do, vs what you can do with PowerShell in VSCode.
I have done multithread in C# with VS Code debugging, but I am not aware of a good process for this in PowerShell. I assume that this is a question of support by the extension, but also the complication, of the various ways that PowerShell avoids or hides literal threading.
PowerShell abstracts async different than other languages.
Someone may be able to give a better summary on these, but "It is complicated"
Upvotes: 2
Reputation: 16106
You are confusing tools and use case and this is due to your misunderstanding of PowerShell and the tools to deal with that, and that would be expected if you've never done this before.
If you have no PowerShell experience, its best to get ramped up first. Jumping into a tool for a language you've never used or understand is not prudent. Jump on Youtube and search for 'Beginning PowerShell' and view some of those before moving any further.
This is not a PowerShell code issue, which is what we are here to help with.
Your question is 'How do I configure VSCode and/or Visual Studio for Powershell development?, and thus off-topic for StackOverflow, and more a question for SuperUsers or StackExchange.
How do I ask a good question? - Help Center - Stack Overflow
Yet since you are here and I use this addon, let me provide some edification.
PowerShell Pro Tools Suite https://ironmansoftware.com/powershell-pro-tools
PowerShell Pro Tools adds script packaging, a Windows Form Designer, code conversion and a Universal Dashboard previewer to VS Code.
PowerShell Pro Tools provides Visual Studio integration through the PowerShell Tools for Visual Studio. The Visual Studio integration provides the following features. Packaging as executables including command line utilities and services Windows Forms Designer WPF Designer Integration Code Conversion
You can view how to use the tool buy view the docs from Ironman software the author of the product or on Youtube. Just search for it.
'powershell pro tools for VSCode'
'powershell pro tools for vscode projects'
Upvotes: 3