VSCode Plug-in Development Overview (10) Packaging, Publishing and Upgrading
After the plug-in has been developed, how to publish it and share it with others? There are three main methods:
Method 1: Send the folder to others directly, let others find the plug-in directory of vscode and put it in, then restart vscode, which is not recommended generally.
Method 2: Package it into a vsix plug-in and send it to someone else to install. If your plug-in involves confidentiality and is not easy to publish to the application market, you can try this way.
Method 3: Register the developer’s account and publish it to the official website application market. This publication, like npm, does not need to be audited.
Whether it’s locally packaged or released to the application market, we need to use VSCE as a tool.
npm i vsce -g
Packed into a vsix file:
Repository will be prompted if it is not set when packaging, so it’s better to set it up.
The generated vsix file cannot be directly dragged into the installation, only Install from VSIX installation can be selected from the upper right corner of the extension:
Publishing application market
Visual Studio CodeThe application market is based on Microsoft’s own Azure DevOps, where plug-ins are authenticated, hosted and managed.
To publish to the application market, we must first have the publisher account of the application market.
To publish accounts, Azure DevOps is the first organization.
Before creating an organization, you have to create an Azure account.
To create an Azure account, you must first have a Microsoft account.
Is it a little dizzy, comb it out a little bit: uuuuuuuuuuu
A Microsoft account can create multiple Azure organizations.
An organization can create multiple publisher accounts.
At the same time, an organization can create multiple PATs (Personal Access Tokens).
3.1. Registered account number
First visit https://login.live.com/login to your Microsoft account. No one registers first:
Then visit: https://aka.ms/Signup Azure DevOps. If you have never used Azure, you will see the following tips:
Click Continue and by default an organization will be created in the name of the mailbox prefix.
3.2. Create token
By default, when you enter the organization’s home page, click Security in the upper right corner:
Click to create a new personal access token, and pay special attention to Organizations choosing all accessible organizations and Scopes choosing Full access, otherwise the conference will fail.
After creating a token successfully, you need to write it down locally, because the website will not save it for you.
3.3. Create publication account
After obtaining the personal access token, create a new publisher using the following command of vsce:
vsce create-publisher your-publisher-name
your-publisher-nameIt must be an alphanumeric underscore, which is the only account on the whole network. Then it will be required to enter nicknames, mailboxes and tokens in turn:
After successful creation, the account will be logged in by default, and then you can publish it directly. Of course, if you created it elsewhere, you can try VSCE login your-publisher-name to login.
In addition to commands, you can also create a publishing account using the Web version: https://marketplace.visual studio.com/management
The release is simple:
It will take a few minutes to find it in the application market after the release is successful. In a few minutes, you can visit the plug-in home page of the Web page: https://marketplace.visual studio.com/items?ItemName=sxei.vs.Code-plugin-demo
vscodeIt can also be found:
3.4.1. Issue notes
README.mdThe file will be displayed on the plug-in home page by default.
README.mdThe resources in HTTPS must be all HTTPS. If HTTP is used, the publication will fail.
CHANGELOG.mdIt will be displayed on the Change tab.
If the code is placed in the GIT repository and the repository field is set, git must be submitted before publication, otherwise Git working directory will be prompted not clean;
In addition, as mentioned earlier, if the Organization does not select all accessible organizations, or Scopes does not select Full access, the following error 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 after release, for example: 1.0.2-> 1.0.3, you can do this:
vsce publish patch
This command automatically modifies the version number in package. json. Similarly, VSCE publish minor is also possible.
3.5. Cancellation of publication
vsce unpublish (publisher name).(extension name)
3.6. To update
If you change the plug-in code to redistribute, you just need to change the version number and then re-execute VSCE publish.
4.1. Released to the application market
If released to the application market, it will generally automatically detect whether there is a new version, or if there is an automatic senseless upgrade, but the exact time to detect has not been studied. What has been determined is that the name of the search plug-in in the expansion panel will automatically detect, and restart the vscode will also detect.
4.2. If it is packaged locally
If it is packaged into v6, then it can only realize the upgrade detection function itself. By comparing the version number of a file on the server, I will not go into details.
Personal website: https://haoji.me
Blog Garden: http://www.cnblogs.com/liuxianan