-->
Page 1 of 1

Build tasks in vscode

PostPosted: Sat Oct 30, 2021 8:14 am
by CestLaGalere
Possibly a question for vscode but I've looked and cannot get it working.
I am using vscode on Windows to Verify / Upload images, I wish to add a pre-build task (UpdateVer) to update the software version using a small powershell script, I have added a section into tasks with a dependsOn dependency but I cannot get it to run - I have added a simpler task (called pre-build) to check things and this also does not run.
Where am I going wrong please?

Code: Select all{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "UpdateVer",
            "detail": "Update the FIRMWARE_VERSION",
            "type": "shell",
            "command": "./../scripts/updateversion.ps1",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            }
        },
        {
            "label": "pre-build",
            "type": "shell",
            "command": "git describe --long > '${workspaceFolder}/version.txt'"
        },
        {
            "label": "build",
            "type": "shell",
            "command": "msbuild",
            "args": [
                // Ask msbuild to generate full paths for file names.
                "/property:GenerateFullPaths=true",
                "/t:build",
                // Do not generate summary otherwise it leads to duplicate errors in Problems panel
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "dependsOn": ["pre-build", "UpdateVer"],
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "silent"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile",
        }
    ]
}

Re: Build tasks in vscode

PostPosted: Sun Oct 31, 2021 11:35 am
by quackmore
I've been using simple vscode tasks (I'm on linux)

this one, from your example, does not work for me

Code: Select all{
    "type": "shell",
    "label": "git version",
    "command": "git describe --long > '${workspaceFolder}/version.txt'"
}


but this one does

Code: Select all{
    "type": "shell",
    "label": "git version",
    "command": "git describe --long > '${workspaceFolder}/version.txt'",
    "options": {
          "cwd": "${workspaceFolder}"
    },
    "problemMatcher": []
}


didn't investigate further...
google search and github are good places for working examples