microsoft / vss-web-extension-sdk

Visual Studio Teams Service Web Extension SDK
https://www.visualstudio.com/docs/integrate/extensions/overview
MIT License
133 stars 87 forks source link

404 when using ReleaseManagement/Core/RestClient #35

Closed goenning closed 7 years ago

goenning commented 7 years ago

Hi,

I'm trying to use ReleaseManagement/Core/RestClient on my widget but it doesn't seem to work.

My code is like this

/// <reference types="vss-web-extension-sdk" />
import WidgetHelpers = require("TFS/Dashboards/WidgetHelpers")
import ReleaseManagementClient = require("ReleaseManagement/Core/RestClient")

export function initialize() {
    WidgetHelpers.IncludeWidgetStyles();
    VSS.register("EnvironmentOverviewWidget",  () => {
        const projectId = VSS.getWebContext().project.id;
        return {
            load: function (widgetSettings) {
                console.log(ReleaseManagementClient);
                console.log(ReleaseManagementClient.getClient);
                var $title = $("h2.title");
                $title.text(`Hello World: ${projectId}.`);

                return WidgetHelpers.WidgetStatusHelper.Success();
            }
        }
    });
    VSS.notifyLoadSucceeded();
}

Which results on console error: GET https://goenning.gallery.vsassets.io/_apis/public/gallery/publisher/goennin…VV0F2NG9YblNITmhEQ2FiQkpGWWNNdmp1bz0=/ReleaseManagement/Core/RestClient.js 404 ()

My vss-web-extension-sdk package is 2.113.0 and i have extension with scope vso.release.

Thanks!

sorosoro2 commented 7 years ago

Hi,

Please add an entry to the"includes" field to your contribution "ms.vss-releaseManagement-web.release-service-data-external" . If you don't have one, please add it { "id": "abcd", "type": "abcd", "includes": [ "ms.vss-releaseManagement-web.release-service-data-external" ], . . }

We have not documented properly for client usages for pages not hosted by RM We'll do so

goenning commented 7 years ago

Thanks @sorosoro2, it worked.

jkulhanek commented 7 years ago

I have the same problem.

aneillans commented 7 years ago

I'm encountering this too.

vss-web-extension-sdk version: 2.116.1 API Version: 3.0 TFS Version: 2017 Update 1

I have the include as above in my contributions section, however, regardless I am encountering a 404 on the plugin when it's trying to load a url such as this: http://tfs2017:8080/tfs/_apis/public/gallery/publisher/variablepublisher/extension/variable/0.0.57/assetbyname/ReleaseManagement/Core/RestClient.js

The same extension loads and operates normally on VSTS.

Am I missing something? Appears the documentation has not been updated yet too. @sorosoro2 any thoughts?

sorosoro2 commented 7 years ago

@aneillans , Do you have the extension published somewhere? Can you share the link of the extension/ vsix with me?

aneillans commented 7 years ago

Yes its published on the marketplace; https://marketplace.visualstudio.com/items?itemName=tenaciousfox.tf-rm-copyvar

If you alternatively provide me an email address am happy to send through any code etc you need.

sorosoro2 commented 7 years ago

We have identified the issue in TFS. We will be fixing it in TFS 2017 update2, RC2 and above

justRu commented 5 years ago

I have the same problem.

I have a build menu item (ms.vss-build-web.build-result-completed-actions-menu) and when it loads my scripts, it tries to load ReleaseManagement/Core/RestClient from assetbyname URL under my extension instead of /_static/tfs/M141_Oct15.4/_scripts/TFS/min/ReleaseManagement/Core/RestClient.js. To work around this problem I modified moduleLoaderConfig in VSS.init, but that's very brittle.

Similar code works just fine from the release toolbar menu action. I suspect there is some script that registers the ReleaseManagement modules, how to invoke it for the build menu?

Adding

"includes": [ "ms.vss-releaseManagement-web.release-service-data-external" ],

to my contribution doesn't make it work.

vss-web-extension-sdk version: 4.126.2 Using the https://msasg.visualstudio.com/ collection.

gereon77 commented 4 years ago

We have identified the issue in TFS. We will be fixing it in TFS 2017 update2, RC2 and above

@sorosoro2 : I also run in this issue. Adding "includes": [ "ms.vss-releaseManagement-web.release-service-data-external" ] to my contribution doesn't help unfortunately.

But there is one interesting point: It seems to only be an issue with Azure DevOps Server 2019 U1. For debugging I installed my extension to a TFS2018U3 test instance and there the extension works like a charm.

I am using the RM Rest client in a Pipelines hub (ms.vss-build-web.build-release-hub-group) and in a dashboard widget. The dashboard widget also works on 2019 perfectly but in the Hub the 404 is thrown in about 3 of 4 cases. Means when I navigate to the Hub by clicking it, it works sometimes and most of the time not. When I refresh the page by hitting F5 it never works.

That is my observation so far.

The code is not public but I could provide it for investigations.

Thank you in advance and

Best regards,

Gereon

@justRu : could you provide your work around with the module loader?

sorosoro2 commented 4 years ago

We have moved our extension model authoring in the last year. Now, we provide the APIs in an npm package, so that it can be consumed by extension authors.

This helps us ensure that there is no break between the client versions used by the extension and the clients hosted inside Azure DevOps.

Please fetch and use azure-devops-extension-api package in your extension authoring code. This package contains all clients including release clients

gereon77 commented 4 years ago

@sorosoro2 Thanks for your quick answer. Migration to the new API package is planned anyways. But right now we wanted to release the new feature without touching the whole code again.

And we finally found a way to work around the issue. BTW... We realized the problem occurs only on 2019U1... On 2019 the 404 is not thrown!

But for all others who are interested here is our work around:

Download contracts.js and restclient.js from

{SERVERURL}/_static/tfs/Dev17.M153.3/_scripts/TFS/min/ReleaseManagement/Core/Contracts.js {SERVERURL}/_static/tfs/Dev17.M153.3/_scripts/TFS/min/ReleaseManagement/Core/RestClient.js

Place the files in your static folder under ReleaseManagement/Core

Add following entry to your files array in your extension manifest:

{
      "path": "static/ReleaseManagement",
      "addressable": true,
      "packagePath": "ReleaseManagement"
}

OR

Place the Releasmanagement/Core folder on the root level (where the manifest lives) of your repo and add this item to the files array:

{
      "path": "ReleaseManagement",
      "addressable": true
}