How do I debug a Windows PowerShell module in Visual Studio?

后端 未结 2 884
一向
一向 2021-02-05 20:07

I\'m trying to write a PowerShell module as a VB.NET project with Visual Studio 2015. I\'ve been able to put a few commands together, compile the class library into a DLL, impo

相关标签:
2条回答
  • 2021-02-05 20:54

    It's possible to debug your cmdlet directly without needing a separate project. Open the properties of your class library project and configure the Debug tab as follows (assuming Windows is installed to C:):

    • Start Action
      • Start external program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    • Start Options
      • Command line arguments: -NoLogo -Command "Import-Module '.\MyModule.dll'; Get-TestCommand;"

    0 讨论(0)
  • 2021-02-05 20:55

    Edit: try this link or this step-by-step

    Either downdload PowerShell Tools for Visual Studio 2015 or use Windows PowerShell ISE.

    How to Debug Scripts in Windows PowerShell ISE

    Updated: October 17, 2013 Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0, Windows PowerShell 4.0, Windows PowerShell 5.0 This topic describes how to debug scripts on a local computer by using the Windows PowerShell® Integrated Scripting Environment (ISE) visual debugging features. How to manage breakpoints How to manage a debugging session How to step over, step into, and step out while debugging How to display the values of variables while debugging
    How to manage breakpoints A breakpoint is a designated spot in a script where you would like operation to pause so that you can examine the current state of the variables and the environment in which your script is running. Once your script is paused by a breakpoint, you can run commands in the Console Pane to examine the state of your script. You can output variables or run other commands. You can even modify the value of any variables that are visible to the context of the currently running script. After you have examined what you want to see, you can resume operation of the script. You can set three types of breakpoints in the Windows PowerShell debugging environment: Line breakpoint. The script pauses when the designated line is reached during the operation of the script...

    0 讨论(0)
提交回复
热议问题