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
See also this guide in the Azure help.
- Login to Azure DevOps.
- See list of organizations aex.dev.azure.com/me.
- Use the default organization or choose one for your project (make it if needed).
- You’ll land at a page like
https://dev.azure.com/myuser/My%20Project. - Click the cog in the top right.
- Click Personal access tokens.
Then edit an existing token or make a new one using steps below:
- Click New Token.
- Give it a Name based on your extension.
- Set Organization to All accessible organizations.
- Optionally extend the expiration date.
- Set Scopes.
- Use Custom defined.
- Click Show all scopes athe bototm.
- Under Marketplace, tick the Manage scope.
- Click Create.
- Copy the token value. Keep this value secret. This is only visible once but you can click Regenerate to get a new value for the same token.
Now you can use the token in the CLI to publish your extension in the section below.
Fix error
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 USERNAMEthen paste your token. - Run
vsce publishagain.
Create and publish release
Install vsce in your project as a dev dependency.
$ npm install -D vsce
$ npx vsce --version
You can install globally instead with -g, but this makes it harder to manage across projects and across 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_NAMEe.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.0thenv1.2.0will be created.$ vsce publish minor - Or, create a specific tag. Note without a
vto 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 publishwith 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.