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
.
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:
- Hover over your profile picture in the upper right corner.
- Select "Security".
- Select the "Personal access tokens" section if not already selected.
- Click the "Add" button to generate a new token.
- If you'd like to limit the scope, select just the "Marketplace (publish)" option.
- Click "Create token".
- 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:
Some things to watch out for:
- Specify http/https.
- You may/may not need to specify the port number.
- 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
- Navigate to the root directory of your extension.
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>

- 192
- 1
- 2
- 16
-
1Since the PAT is like a password I would strongly suggest NOT to save it in clear text in any script. You should use "tfs login --service-url
--token – Flex Jul 06 '17 at 12:22" manually. This connection will be cached and can be reused. So you don't need to reenter credentials every time you publish an extension. -
@Flex Thanks for the tip. I don't keep the token hardcoded in my script at work, but I edited my answer to use the `tfx login` command first and subsequent commands sans token in the interest of preventing readers from making that mistake. – broAhmed Jul 07 '17 at 18:05