question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extensions cannot be installed from a release definition

See original GitHub issue

I am unable to install extensions from a release definition. If I do so, I get the following error:

D:\01\_work\_tools\tfx.cmd extension install --auth-type pat --token ********** --vsix "D:\01\_work\r9\a\myextension-1.0.6.gen.vsix" --service-url https://mytfsserver.com/tfs/MyCollection
TFS Cross Platform Command Line Interface v0.6.4
Copyright Microsoft Corporation
error: SyntaxError: Unexpected token < in JSON at position 2

After I enable debug logging I get more error logging:

2019-02-26T14:10:39.003Z : SyntaxError: Unexpected token < in JSON at position 2
2019-02-26T14:10:39.003Z :     at JSON.parse (<anonymous>)
2019-02-26T14:10:39.003Z :     at Function.<anonymous> (D:\01\_work\_tools\node_modules\tfx-cli\_build\exec\extension\in
stall.js:217:45)
2019-02-26T14:10:39.003Z :     at step (D:\01\_work\_tools\node_modules\tfx-cli\_build\exec\extension\install.js:45:23)
2019-02-26T14:10:39.003Z :     at Object.next (D:\01\_work\_tools\node_modules\tfx-cli\_build\exec\extension\install.js:
26:53)
2019-02-26T14:10:39.003Z :     at fulfilled (D:\01\_work\_tools\node_modules\tfx-cli\_build\exec\extension\install.js:17
:58)
2019-02-26T14:10:39.003Z :     at process._tickCallback (internal/process/next_tick.js:68:7)

The code that throws the error is on this line: https://github.com/Microsoft/tfs-cli/blob/457a7a320d84d9a732eb812232619d2940c2299d/app/exec/extension/install.ts#L182

The response in this case is an HTML page and not the expected JSON:

...
<h1>Error</h1>
<h2>The page you are looking for is currently unavailable.</h2>

<div id="errorMessage" style="font-size: 24px; color: #da0a00; margin-top: 30px; margin-bottom: 30px;">TF400813: Resource not available for anonymous access. Client authentication required.</div>
....

The function that is trowing the error in install.ts does not do anything with authentication. It just requests the url https://mytfsserver.com/tfs/MyCollection/_apis/resourceareas/6c2b0933-3600-42ae-bf8b-93d4f7e83594 which in my case returns null.

A workaround for this is to change this line: https://github.com/Microsoft/tfs-cli/blob/master/app/exec/extension/install.ts#L101

Into: const serviceUrl = await this.commandArgs.serviceUrl.val();

My TFS instance version is 16.131.28507.4 (TFS 2018 Update 3.2)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
gereon77commented, Mar 28, 2019

@jessehouwing @simondel : I created an own extension just for uploading FREE extensions to an Azure DevOps Server (OnPrem). I clarify with my boss if I can provide the full source code. Unfortunately it’s PS because my TS skillz are just read, not contribute… 😉

So far the core functions to make it work are:

Following headers need to be applied to every REST call:
$headers = @{'Accept'="application/json; api-version=4.0; excludeUrls=true"}

And for PUT/POSTS ContentType has to be set to 'application/json'

1. read Id, Version and Publisher from vsix manifest
2. check if extension is already installed:
  GET $tfsServerUrl/_apis/gallery/publishers/$($vsixManifest.Publisher)/extensions/$($vsixManifest.Id)?flags=1
    - On 200: Already installed => Read current version from result body: Max(versions.version) => If manifest version is higher => Prepare a PUT
    - On 404 (or everything else) => Prepare a POST
3. Upload the extension:
  - Convert the vsix file in a base64 string and prepare the body:
    $bytes = [IO.File]::ReadAllBytes($vsixPath)
    $base64 = [Convert]::ToBase64String($bytes)
    $uploadJson = @{ extensionManifest = $base64 } | ConvertTo-Json -Compress
  - POST $tfsServerUrl/_apis/gallery/extensions
  - OR PUT $tfsServerUrl/_apis/gallery/publishers/$($vsixManifest.Publisher)/extensions/$($vsixManifest.Id)
4. On 201 or 200 Validate extension:
  - GET $tfsServerUrl/_apis/gallery/publishers/$($vsixManifest.Publisher)/extensions/$($vsixManifest.Id)?flags=1
  - Search the versions array again for the item where version = $vsixManifest.Version
  - If validationResultMessage message is set => error
  - If flags contains "validated" => ok
  - If validationResultMessage is null and flags doesn't contain "validated" => still in progress, retry after 5 seconds for 3 minutes
5. If validation succeeded => Install to collections:
  - Prepare install body: $installBody = @{assignmentType = 0; billingId = $null; itemId = "$($vsixManifest.Publisher).$($vsixManifest.Id)"; operationType = 1; quantity = 0; properties = @{} } | ConvertTo-Json -Compress
  - POST $tfsServerUrl/$collection/_apis/ExtensionManagement/AcquisitionRequests
6. On 200: => Done
0reactions
gereon77commented, Apr 30, 2019

This is fixed in master. Should have an update published today.

Verified today. Install now workds. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Initially installing the release version of an extension that has ...
Testing #138086 Find a not-yet-installed extension for which a pre-release exists. Choose to install the Release version.
Read more >
Install extensions - Azure DevOps | Microsoft Learn
Learn how to install, assign, and uninstall extensions for Azure DevOps.
Read more >
As Azure DevOps owner, I cannot install extensions
A workaround is to use a MSA identity to install the extension. Customer used MSA identity to install and unblock. Just try to...
Read more >
JFrog Azure DevOps Extension
Select the JFrog extension located in the Build and Release section. In the JFrog Extension page, click Install. Select the account to which...
Read more >
Documentation: 15: CREATE EXTENSION - PostgreSQL
For many extensions this means superuser privileges are needed. However, if the extension is marked trusted in its control file, then it can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found