Vscode plug-in development strategy package, release, upgrade detailed tutorial

Time:2020-12-3

1、 Release method

After the plug-in is developed, how to release it and share it with others? There are three main methods

  • Method 1: directly send the folder to others, let others find the directory where vscode plug-ins are stored and put it in it, and then restart vscode, which is generally not recommended;
  • Method 2: package it into a vsix plug-in and send it to others for installation. If your plug-in involves secrets and is not convenient to publish to the application market, you can try this method;
  • Method 3: register the developer’s account and publish it to the official website application market. This release, like NPM, does not need to be approved.

2、 Local packaging

Whether it’s local packaging or publishing to the application market, you need to use thevsceThis tool.

Installation:


npm i vsce -g

Packed intovsixDocument:


vsce package

If there is no setting when packingrepositoryThere will be a prompt, so it’s better to set it.

The generated vsix file cannot be directly dragged into the installation, and can only be selected from the upper right corner of the extensionInstall from VSIXInstallation:

3、 Release application market

The application market of visual studio code is based on Microsoft’s ownAzure DevOps, plug-in authentication, hosting and management are all here.

To publish to the application market, there must be an application marketpublisherAccount number; and to have a publishing account, you must first have oneAzure DevOpsOrganization; and before you create an organization, you have to create itAzureAccount number; createAzureYou have to have an account number firstMicrosoftaccount number;

It’s a little dizzy. Let’s sort it out

One Microsoft account can create multipleAzureOrganizations; an organization can create multiplepublisherAccount number; an organization can create multiple accounts at the same timePATPersonal Access Token, personal access token);

Registered account number

First visit https://login.live.com/ Log in to yourMicrosoftIf you don’t have one, register one first

Then visit: https://aka.ms/SignupAzureDevOps , if you have never used azure, you will see the following prompt:

Click continue to create an organization with the name of mailbox prefix by default.

Create token

After entering the homepage of the organization by default, clickSecurity

Click to create a new personal access token, especially hereOrganizationTo chooseall accessible organizationsScopesTo chooseFull accessOtherwise, the subsequent press conference will fail.

After the token is created successfully, you need to write it down locally, because the website will not save it for you.

Create publishing account

After obtaining the personal access token, use thevsceThe following command creates a new Publisher:


vsce create-publisher your-publisher-name

your-publisher-nameIt must be an alphanumeric underline, which is the only account in the whole network. Then, it will ask for the nickname, mailbox and token in turn:

After successful creation, you will log in to this account by default. Next, you can publish it directly. Of course, if you created it in other places, you can try it outvsce login your-publisher-nameTo log in.

In addition to using commands, you can also use the web version to create a publishing account: https://marketplace.visualstudio.com/manage

release

The release is simple:


vsce publish

It will take a few minutes to find it in the app market. In a few minutes, you can visit the home page of the web version of the plug-in: https://marketplace.visualstudio.com/items?itemName=sxei.vscode-plugin-demo

You can also find it in vscode:

Release notesREADME.mdThe file will be displayed on the plug-in home page by default;README.mdAll resources in must beHTTPSYes, if it isHTTPFailed to publish;CHANGELOG.mdIf the code is placed in the GIT repository and the repository field is set, GIT must be submitted before publishing, otherwise it will be promptedGit working directory not clean

In addition, as mentioned above, ifOrganizationThere is no choiceall accessible organizationsOrScopesThere is no choiceFull accessThe following errors may be reported when publishing:

Error: Failed Request: Unauthorized(401) – https://marketplace.visualstudio.com/_apis/gallery
Be sure to use a Personal Access Token which has access to **all accessible accounts**.
See https://code.visualstudio.com/docs/tools/vscecli#_common-questions for more information.

3.4.2 incremental release

Version number:major.minor.patch

If you want to increase the patch number automatically after the release, for example:1.0.2 -> 1.0.3It can be as follows:


vsce publish patch

This command will be modified automaticallypackage.jsonThe version number inside. In the same way,vsce publish minorIt’s OK.

3.5 cancel Publishing


vsce unpublish (publisher name).(extension name)

3.6 update

If you modify the plug-in code and want to redistribute it, just change the version number and execute it againvsce publishThat’s fine.

4. Plug in upgrade

4.1 was released to the application market

If it is released to the application market, generally speaking, it will automatically detect whether there is a new version, and if some will be automatically upgraded without perception. However, I have not studied the specific time to detect it. What has been determined is that searching for the plug-in name in the extension panel will automatically detect it, and restarting vscode will also detect it.

4.2 in case of local packaging

If it is packaged intovsixThen you can only realize the upgrade detection function by yourself. By comparing the version number of a file on the server, I will not elaborate on the details.

summary

This article on the vscode plug-in development strategy (10) package, release, upgrade article introduced here, more related vscode packaging, release, upgrade content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!

Recommended Today

Summary of recent use of gin

Recently, a new project is developed by using gin. Some problems are encountered in the process. To sum up, as a note, I hope it can help you. Cross domain problems Middleware: func Cors() gin.HandlerFunc { return func(c *gin.Context) { //Here you can use * or the domain name you specify c.Header(“Access-Control-Allow-Origin”, “*”) //Allow header […]