Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
November 14, 2023

More Tasks with VSCode

We’ve been looking at how to set up tasks in VS Code. This is a handy way to execute common activities. You can streamline your workflow with a few keystrokes. For example, I always generate external help for my modules. Creating the markdown documents is a recurring activity. I can simplify the process by adding a task to the tasks.json file.

{
    "label": "Build markdown help files (PS 7)",
    "type": "shell",
    "command": "-command &{$module = Split-Path $pwd -leaf;Write-Host \"Creating help for $module\" -foreground yellow;Import-Module $pwd\\$module.psd1 -force;New-MarkdownHelp -module $module -output $pwd\\docs -force}",
    "options": {
        "shell": {
            "executable": "pwsh.exe",
            "args": [
                "-noprofile"
            ]
        }
    }
}

When creating the markdown documents, I need to make sure the current version of the module is loaded into my session. Then, I can create the new markdown documents. The module I’m working on in this location requires PowerShell 7, so I must use the correct executable. It is easy enough to copy and paste this task and edit it to use PowerShell.exe for my legacy modules.

Remember, the command value is a single string, which is why I am using the semi-colon command separator.

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.