首页 > 解决方案 > 在 VS Code 中调试 Powershell cmdlet(用 c# 编写)

问题描述

另一个问题解决了如何在 Visual Studio 2015-19 中调试用 C# 编写的 Powershell cmdlet: 调试/卸载 PowerShell Cmdlet

我可以以某种方式调用这样的脚本:

function Start-DebugPowerShell
{
    PowerShell -NoProfile -NoExit -Command {
        function prompt {
            $newPrompt = "$pwd.Path [DEBUG]"
            Write-Host -NoNewline -ForegroundColor Yellow $newPrompt
            return '> '
        }
    }
}
Set-Alias -Name sdp -Value Start-DebugPowerShell

这使得创建可以exit卸载的临时 PS 实例变得容易。

或者我可以像这样在 VS 项目中设置调试选项,效果很好: 在此处输入图像描述

我想做同样的事情,但使用 Visual Studio Code。我知道如何使用附加进行调试(例如,使用以下launch.json设置:

    {
        "name": ".NET Core Attach",
        "type": "coreclr",
        "request": "attach",
        "processId": "${command:pickProcess}",
        "justMyCode": false
    }

我不知道如何制作launch.json第一次发布pwsh。项目类型是csharp,因此唯一type可用的 slaunch.jsoncoreclrclr

标签: c#powershellvisual-studio-codevscode-debuggercmdlets

解决方案



推荐阅读