Edit

Share via


Publish an Azure DevOps extension from the command line

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022

Use the Cross-platform CLI for Azure DevOps (tfx-cli) to publish your extension to the Visual Studio Marketplace. For more information, see the overview of publish, install, and share.

Prerequisites

Category Requirements
Tools Cross-platform CLI for Azure DevOps (tfx-cli) installed via npm
Authentication A Microsoft Entra token (recommended) or a personal access token (PAT) with Marketplace (publish) scope
Publisher A publisher account set up in the Visual Studio Marketplace

Important

Consider using the more secure Microsoft Entra tokens over higher-risk personal access tokens. For more information, see Reduce PAT usage. Review the authentication guidance to choose the right authentication mechanism for your needs.

Acquire the Cross-platform CLI for Azure DevOps

  1. If you don't have it, download and install NodeJS. During set up, ensure that you leave Add to PATH chosen.

  2. Open a Command Prompt and enter npm i -g tfx-cli.

If you already have the TFX CLI installed, you can update to the latest release by running npm up -g tfx-cli.

Install the Cross-platform CLI for Azure DevOps

npm install -g tfx-cli

Publish with a Microsoft Entra token as a service principal

You can publish an extension as a service principal.

  1. Add the service principal as a member to a publisher account. Get the service principal's ID through the REST API by signing in via the Azure CLI and querying the service principal's profile:
az login --service-principal --username <appId> --password <password> --tenant <tenant-id>
# 499b84ac-1321-427f-aa17-267ca6975798 specifies azure devops as a resource
az rest -u https://app.vssps.visualstudio.com/_apis/profile/profiles/me --resource 499b84ac-1321-427f-aa17-267ca6975798

Then, use the ID from the previous step to add the service principal as a member to the publisher.

  1. Publish an extension via TFX CLI using a service principal. Run the following TFX CLI command to use its access token:
tfx extension publish --publisher my-publisher --vsix my-publisher.my-extension-1.0.0.vsix --auth-type pat -t <ENTRA_TOKEN>

Publish with a personal access token

Create a personal access token (PAT) with Marketplace (publish) scope.

After you install tfx-cli and have your PAT, package and publish your extension.

  1. Open a command prompt to the root directory of your extension.
  2. Run the following command to publish your extension. When prompted, enter your token to authenticate.
tfx extension publish --publisher <YOUR_PUBLISHER_ID> --manifest-js <YOUR_EXTENSION_MANIFEST> --share-with <ACCOUNT_NAME>

Potential errors

You might receive the following error if your extension is already published:

Failed Request: Internal Server Error(500) - Version number must increase each time an extension is published. Extension: fabrikam.my-extension  Current version: 0.1.9  Updated version: 0.1.9

Add the --rev-version flag to automatically increment the patch version of your extension. This flag also saves the new version to your manifest.

Note

All options available for create are available for the publish command.

Example

C:\vso-team-calendar>tfx extension publish --publisher publishFabrikam --manifest-js fabrikam.config.js --share-with fabrikam --rev-version
Copyright Microsoft Corporation
> Personal access token:
Checking if this extension is already published
It is, update the extension
Waiting for server to validate extension package...
Sharing extension with fabrikam.

=== Completed operation: publish extension ===
 - Packaging: C:\vso-team-calendar\fabrikam.team-calendar-0.2.6.vsix
 - Publishing: success
 - Sharing: shared with fabrikam