1

I have written some PowerShell Modules in C#. I know how to debug them in Visual Studio. (With stepping through etc.) Is there a way to debug C# PowerShell Modules in Visual Studio Code?

2
  • 1
    Since Visual Studio Code supports C# projects, you can also debug C# projects that happen to be PowerShell modules (source code of binary cmdlets). Commented Feb 3, 2023 at 13:36
  • But how? Binary Modules are just class libraries. I need a powershell script that calls this library but i don't know how to attach the process so that the breakpoint in the C# code will be hit. Commented Feb 3, 2023 at 13:44

1 Answer 1

2
  1. In the debug tab select "Generate C# Assets for Build and Debug"
  2. List item
  1. Set breakpoint
  2. Start debug and choose the pswh console process
  3. Import module and use cmdlet
Sign up to request clarification or add additional context in comments.

2 Comments

Where is the "debug tab"? I cannot find it.
In the menu bar on the left side is "Run and Debug". (CTRL+Shift+D)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.