Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the tfs-cli (tfx) to update a TFS extension for an on-premise TFS instance?

Tags:

tfs

My company has a on-premise TFS 2017 instance. I know how to install and update extensions through the web interface, but it's pretty tedious. I'm wondering if there's a quicker way to do it with tfs-cli.

like image 834
broAhmed Avatar asked Jun 30 '17 19:06

broAhmed


1 Answers

Took me awhile to figure this out for some reason. At first I thought tfs-cli could only be used to publish extensions to the Visual Studio Marketplace, but that's not the case. Here's how to do it for on-prem TFS:

Generate a personal access token

You can follow the instructions here. Or:

  1. Hover over your profile picture in the upper right corner.
  2. Select "Security".
  3. Select the "Personal access tokens" section if not already selected.
  4. Click the "Add" button to generate a new token.
  5. If you'd like to limit the scope, select just the "Marketplace (publish)" option.
  6. Click "Create token".
  7. Copy it and keep it somewhere safe!

Login

Enter the following in the commandline:

tfx login

You'll be prompted to enter the service URL and the personal access token you generated in the last step.

For the service URL, use whatever your company uses to access TFS. Example URLs:

  • http://tfs.company.domain:8080/tfs/
  • https://tfs.company.domain/tfs/
  • https://tfs.company.domain/

Some things to watch out for:

  1. Specify http/https.
  2. You may/may not need to specify the port number.
  3. Depending on what version of TFS 2017 you're running and how it was installed, you may or may not need to include /tfs/ in the URL. For example, it's possible to get rid of the /tfs/ virtual directory when installing. Look at the URL you use when you use TFS in your browser and your command accordingly.

Package your extension

  1. Navigate to the root directory of your extension.
  2. tfx extension create --manifests <manifest-file-name> --rev-version
    • --manifests flag is used for specifying the filename of your manifest, e.g. vss-extension.json
    • --rev-version flag will automatically increment the patch number of your package.

Publish (install/update) your extension

Use the publish command to install/update (it'll figure out which needs to be done) your extension.

tfx extension publish --service-url <tfs-url>

You need to specify the service URL again here. If you don't, tfx will attempt to publish your extension to the VSS marketplace.

Lastly, my preferred script:

rm *.vsix &&    # Remove old packages
tfx extension create --manifests <manifest-file-name> --rev-version &&
tfx extension publish --service-url <tfs-url>
like image 169
broAhmed Avatar answered Nov 11 '22 04:11

broAhmed