7
votes

I created a new extension for TFS following MS tutorial. For some reason when I'm adding Icon to my extension I can see this icon when I'm installing the extension and in the "Extension Manager" page,

But when I choose my extension from the build step menu the image is missing.

In the "vss-extension.json" file I added:

"icons": {
    "default": "images/icon.png"
}, 
"files": [
    {
        "path": "images",
        "addressable": true          
    },
    {
        "path": "dist",
        "addressable": true,
        "packagePath": "scripts"
    },
    {
        "path": "infoTab.html",
        "addressable": true
    },                   
    {
        "path": "node_modules/vss-web-extension-sdk/lib",
        "addressable": true,
        "packagePath": "lib"
    },    
    {
        "path": "buildtask"
    }       
],

The image file is 32x32

Should this image be reference in the "task.json" file as well?

2

2 Answers

15
votes

The accepted answer is not correct for Microsoft Visual Studio Team Foundation Server version 15.105.25910.0. Perhaps it was correct for previous versions.

  1. The image file must be named icon.png.
  2. The image file must be in the same folder as task.json.
  3. The image file should be 32 x 32; no image scaling is applied.

The task.json file does not contain any reference to this file. It is located by using these conventions.

9
votes

The task itself has its own icon and it must be stored in the same directory as the task.json and must be called icon.png and be 32x32 pixels and optionally an additional icon.svg can be put alongside it. This has to do with the fact that one extension can contain multiple build tasks, each build task then has its own icon. It's not referenced from the task.json, the correct file name will cause it to be picked up.

For an example, check my Azure Pipelines Snyk task. Also, if this is your complete extension manifest, then it's missing the Build task contribution point:

"contributions": [
{
  "id": "buildtask",
  "type": "ms.vss-distributed-task.task",
  "targets": [
    "ms.vss-distributed-task.tasks"
  ],
  "properties": {
    "name": "buildtask"
  }
}