Closed
Description
Hi,
I can't find a standard way to debug functions in psm1 files.
I've hacked together that more or less works for me now but it's incomplete:
- adjust launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell",
"type": "PowerShell",
"request": "launch",
"program": "Invoke-PSake",
"args": ["${workspaceRoot}\\Debug.ps1", "Debug", "-parameters @{\"ModuleFile\"=\"${file}\"}"]
}
]
}
- add Debug.ps1
`properties{
$ModuleFile
}
Task Debug {
echo "debugging"
Import-Module $ModuleFile
$moduleName = [io.path]::GetFileNameWithoutExtension($ModuleFile)
$command = Get-Command -Module $moduleName
if ($command.Length -gt 1) {
Write-Host "More than one exported command in the module you want to debug."
} else {
& $command
}
}`
This works rather well if you are debugging modules with only one exported command and that doesn't require any parameters.
Metadata
Metadata
Assignees
Labels
No labels