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

Posted by: Gouri Sohoni , on 1/2/2017, in Category VSTS & TFS (Azure DevOps)
Views: 16543
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.

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Author
Gouri is a Trainer and Consultant on Azure DevOps and Azure Development. She has an experience of three decades in software training and consulting. She is a graduate from Pune University and PGDCA from Pune University. Gouri is a Microsoft Most Valuable Professional (MVP)  - Developer Technologies (Azure DevOps), Microsoft Certified Trainer (MCT) and a Microsoft Certified Azure DevOps Engineer Expert. She has conducted over 150 corporate trainings on various Microsoft technologies. She is a speaker with Pune User Group and has conducted sessions on Azure DevOps, SQL Server Business Intelligence and Mobile Application Development. Gouri has written more than 75 articles on Azure DevOps, TFS, SQL Server Business Intelligence and SQL Azure which are published on www.sqlservercurry.com and www.dotnetcurry.com. You can connect with her on LinkedIn.


Page copy protected against web site content infringement 	by Copyscape




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