DotNetCurry Logo

Build and Release Task for Extensions of Visual Studio Team Services (VSTS)

Posted by: Gouri Sohoni , on 1/2/2017, in Category Visual Studio, VSTS & TFS
Views: 8831
Abstract: Create a Build Task that automates package, publish, share and installation of a VSTS extension.

A previous article Create a VSTS Extension that uses Azure Functions explained a step by step process to create VSTS Extension, package into .vsix file, publish to Visual Studio Marketplace, Share the extension to VSTS Account and finally install it. In this article, we will use the already created extension and use a Build Task that automates package, publish, share and installation of the extension.

 

Prerequisites

  • VSTS account
  • Already created package for extension .vsix file
  • Personal Access Token (PAT) for Endpoint (discussed later in the article)

Build and Release Tasks for Extensions

Let us first Install “Build and Release Tasks for Extensions” task from this url. This task includes Package, Publish, Share, Install and Query Version. When we give an extension and the manifest file to that task, the package will be created. We can also provide an already existing package i.e. the .vsix. The extension can be published either privately or publicly. The extension can be shared with one or more VSTS accounts and installed. We can even query version of an already existing VSTS extension.

The curious thing is that this task itself is bundled to form another extension which we can install for a particular VSTS account.

install-task-from-marketplace

Click on Install. The installation wizard will prompt you to specify which VSTS account should this extension be available to.

build-task-to-vsts-ac

After clicking on the continue button, confirm the account name

build-task-confirmed-to-ac

The next step is to go to the account and confirm that this extension is actually available.

Personal Access Token for Marketplace

Now that the extension is available, we need to create PAT (Personal Access Token) endpoint for the Marketplace, and finally a build definition which uses this extension.

Let us see how to create a Personal Access Token. Select ‘Security’ menu item from the VSTS account’s drop down menu for account owner.

security-vsts

Select Personal Access Token and click on Add

personal-access-token-page

Now provide a description, select the number of days the token should be active, and select “All Accessible Accounts”. Even though you may want to apply it to a single VSTS account, the task that we are targeting requires the PAT for “All Accessible Accounts”. Selecting “All accessible accounts” is a very important step because if you select it only for the current account, the build will fail later. The Scope can be set for the Marketplace (Publish).

Once you click on the Create Token button, a token will be displayed. Remember to copy it as you cannot access it later which publishing the extension.

personal-access-token

Upload the working .vsix file which later can be provided with the task configuration. To do so, open the team project that you are working on and click the code menu item. You will see the link to ‘Upload existing  files’. When you select browse, a dialog box to select and upload the file will open.

upload-vsix

Now that all preliminaries are done, it is time for actual publishing of VSTS extension.

Publishing VSTS Extension

Start with an empty build definition if there is no code to build or test to be executed. Add the task of “Build and Release Tasks for Extensions” and configure it.

extension-task-build-def

For configuration, we need to create an endpoint. Click on Manage for a Marketplace connection.

query-extension

Select Marketplace to create a new endpoint, enter the name and provide the PAT you have already copied.

endpoint-creation

Once the endpoint is ready, you need to provide the path to .vsix file (which has already been uploaded).

Publisher ID, Extension ID, Extension Name and Extension Version will be kept as available in the package.

In case we need to change the values, we can provide them with extension name and extension version which will be overridden. Queue the build and the extension will be published on the publishers’ page. We can view it at https://marketplace.visualstudio.com/manage/publishers\

queue-build

In case we want to share the extension to one or more VSTS instances, we can provide the list in Share with textbox at the time of configuration. Ensure to enter only the account name for sharing. If you do any changes to the build definition and trigger the build, make sure to change the version number for the extension. If you forget this step, you will get an error that says the same version number cannot be uploaded.

share-with-acs

When we install “Build and Release Tasks for Team Services”, we get two more steps named Query Extension and Share Extension similar to Publish Extension.

We can use the step for Query Extension Versions to find out the version for any extension. We should know the publisher id and extension id in order to execute this.

query-extension

The installation of the extension to accounts will be taken care of by the Share Extension task. This task can be configured to provide either the .vsix file or providing the extension and publisher id.

share-extension

Conclusion

In this article, we explored another way of publishing and sharing a VSTS extension.

Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+
Further Reading - Articles You May Like!
Author
Gouri Sohoni is a Trainer and Consultant for over two decades. She specializes in Visual Studio - Application Lifecycle Management (ALM) and Team Foundation Server (TFS). She is a Microsoft MVP in VS ALM, MCSD (VS ALM) and has conducted several corporate trainings and consulting assignments. She has also created various products that extend the capability of Team Foundation Server.


Page copy protected against web site content infringement 	by Copyscape




Feedback - Leave us some adulation, criticism and everything in between!