đź“ť Edit page
âž• Add page
Publish
How to publish a VS Code extension to the Marketplace using Azure DevOps
Set up project
- Make a GitHub repo.
- For structure, see VS Code’s docs or see my vsc-extension-quickstart template.
- Make sure to include script commands in
package.json
.
- Set up your extension in the Marketplace.
- Go to Azure DevOps.
- Sign up - use your GitHub account if you want.
- Create a new org or use the default one when registering.
- Create a publisher.
Manage tokens
- Login to Azure DevOps.
- Click your icon.
- Click the 3 dots menu to expand.
- Click User Settings.
- Click Personal access tokens.
Then edit an existing token or make a new one using steps below:
- Click New Token.
- Give it a Name.
- Set Organization to All accessible organizations.
- Optionally extend the expiration date.
- Set Scopes.
- Use Custom defined.
- Click Show more scopes.
- Under Marketplace, tick the Manage scope.
- Click Create.
- Copy the token value. Keep this value secret. If you need the token again, you have to make a whole new token - you can’t regenerate the value for an existing token.
I sometimes get a Segmentation fault error from vsce publish
. This was fixed like this:
- Delete old token on Azure DevOps.
- Make a new token.
- Run
vsce login USERNAME
then paste your token. - Run
vsce publish
again.
Create and publish release
Install vsce
at the project level. This will be in package.json
of the project so is easy to control.
$ npm install -D vsce
$ npx vsce --version
You can install globally instead with -g
, but this makes it harder to manage across projects and machines of devs.
Publish your extension using the CLI.
- Check which files will be packaged.
$ vsce ls
- Use the login command. This won’t have to be run again, until you generate a new token or the old one expires.
- Login with your publisher name.
$ vsce login PUBLISHER_NAME
e.g.
$ vsce login MichaelCurrin
- Paste your token from Azure DevOps.
- Login with your publisher name.
- Use the publish command.
- Increment a minor tag version. e.g. if you are on
v1.1.0
thenv1.2.0
will be created.$ vsce publish minor
- Or, create a specific tag. Note without a
v
to avoid error.$ vsce publish 1.2.3
- Publish an extisting tag. Note flags to avoid errors.
$ vsce publish 1.2.3 --no-git-tag-version --no-update-package-json
- Warning - if you use just
vsce publish
with no args, it will use the latest commit but publish under the latest tag (which could be some commits back).
- Increment a minor tag version. e.g. if you are on
Verify your extension in the Marketplace.
- Go to VS Code Marketplace.
- Sign in.
- Click Publish extensions. e.g. marketplace.visualstudio.com/manage/publishers/MichaelCurrin
- Click More actions next to your extension name.
- Click View extension. e.g. marketplace.visualstudio.com/items?itemName=MichaelCurrin.auto-commit-msg.
Add CI/CD flow
The publishing could be done with CI.
Such as with GH Actions whenever a tag is made.
One would need a non-expiring token added to secrets.
And you’d still need to verify the extension in the Marketplace to see it looks good.