Set up project

  1. 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.
  2. Set up your extension in the Marketplace.
    1. Go to Azure DevOps.
    2. Sign up - use your GitHub account if you want.
    3. Create a new org or use the default one when registering.
    4. Create a publisher.

Manage tokens

  1. Login to Azure DevOps.
  2. Click your icon.
  3. Click the 3 dots menu to expand.
  4. Click User Settings.
  5. Click Personal access tokens.

Then edit an existing token or make a new one using steps below:

  1. Click New Token.
    1. Give it a Name.
    2. Set Organization to All accessible organizations.
    3. Optionally extend the expiration date.
    4. Set Scopes.
      1. Use Custom defined.
      2. Click Show more scopes.
      3. Under Marketplace, tick the Manage scope.
    5. Click Create.
  2. 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:

  1. Delete old token on Azure DevOps.
  2. Make a new token.
  3. Run vsce login USERNAME then paste your token.
  4. 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.

  1. Check which files will be packaged.
     $ vsce ls
    
  2. Use the login command. This won’t have to be run again, until you generate a new token or the old one expires.
    1. Login with your publisher name.
       $ vsce login PUBLISHER_NAME
      

      e.g.

       $ vsce login MichaelCurrin
      
    2. Paste your token from Azure DevOps.
  3. Use the publish command.
    • Increment a minor tag version. e.g. if you are on v1.1.0 then v1.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).

Verify your extension in the Marketplace.

  1. Go to VS Code Marketplace.
  2. Sign in.
  3. Click Publish extensions. e.g. marketplace.visualstudio.com/manage/publishers/MichaelCurrin
  4. Click More actions next to your extension name.
  5. 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.