问题
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:
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:
- http://tfs.company.domain:8080/tfs/
- https://tfs.company.domain/tfs/
- https://tfs.company.domain/
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>
来源:https://stackoverflow.com/questions/44853350/how-do-i-use-the-tfs-cli-tfx-to-update-a-tfs-extension-for-an-on-premise-tfs-i