Search code examples
azure-devopsazure-devops-extensions

Custom release def context command broke in Azure DevOps 2019


I have a TFS extension with some context commands for release definitions. The contribution record in the manifest goes:

    {
        "id": "foo",
        "type": "ms.vss-web.action",
        "description": "...",
        "targets": ["ms.vss-releaseManagement-web.release-definition-explorer-context-menu"],
        "properties":
        {
            "title": "Foo",
            "text": "Foo",
            "icon": "images/foo-16.png",
            "group": "actions",
            "uri": "web/main.html"
        }
    },

The main.html, which implements the command, goes:

function OnFoo(SrcCtxt)
{
    //...
}

VSS.init({ usePlatformScripts: true });
VSS.register("foo", {execute: OnFoo});

It worked in TFS 2015..2018, broke in 2019. The Foo command can be seen in the menu, when you click it, main.html loads (you can see that via the dev tools), but the OnFoo function is not invoked.

The console displays the following:

No handler found on any channel for message: {"id":1,"methodName":"","instanceId":"MyPublisher.myext.foo","instanceContext":{"definition":{"id":1,"name":"Sample release definition","path":"\"}},"params":null}

The version of VSS.SDK.js is the latest, just redownloaded.

EDIT: my working theory is that I'm not registering the command right. Historically, there's been two ways of registering one - via an object an via a function. Replaced my code with the latter, got another message in the console:

Uncaught (in promise) The registered object MyPublisher.myext.foo could not be found.


Solution

  • While poking around samples, I've found an extra line under contribution properties - registeredObjectId. Once I've added that to my manifest, the commands would work like they did before. The value of that property has to match the first argument to VSS.register(), where contribution ID used to be.

    Not cool, Microsoft. Not cool.


    EDIT: other stuff in the extension broke, too. For one thing, JQuery's $ object doesn't seem available anymore. No longer fit for the StackOverflow format, it's a blog post now.