vscode插件开发

1.vscode插件开发官方文档地址

https://www.bookstack.cn/read/CN-VScode-Docs/README.md

2.vscode插件脚手架

全局安装vscode插件脚手架命令和代码生成器

npm install -g yo generator-code

生成vscode脚手架项目

yo code

3.开发

打开vscode插件项目,f5运行项目,ctrl+shift+p 输入默认命令 test.helloWorld,vscode出现弹窗 Hello World from vscode插件项目名!

extension.ts进行相应命令函数的编写

// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {// Use the console to output diagnostic information (console.log) and errors (console.error)// This line of code will only be executed once when your extension is activatedconsole.log('Congratulations, your extension "test" is now active!');// The command has been defined in the package.json file// Now provide the implementation of the command with registerCommand// The commandId parameter must match the command field in package.jsonlet disposable = vscode.commands.registerCommand('test.helloWorld', () => {// The code you place here will be executed every time your command is executed// Display a message box to the uservscode.window.showInformationMessage('Hello World from space-delete-test!');});context.subscriptions.push(disposable);
}// this method is called when your extension is deactivated
export function deactivate() { }

完成新命令后需要修改package.json

{"name": "test","displayName": "space-delete-test","description": "space-delete","version": "0.0.1","engines": {"vscode": "^1.60.0"},"categories": ["Other"],"activationEvents": [    // vscode拓展的激活事件   "onCommand:test.h"    // 此处需要修改为extension.ts对应的命令名],"main": "./dist/extension.js","contributes": {"commands": [                  // 为命令行提供命令{"command": "test.h",   // 此处需要修改为extension.ts对应的命令名"title": "Hello World" // 命令输入时显示的标题}]},"scripts": {"vscode:prepublish": "npm run package","compile": "webpack","watch": "webpack --watch","package": "webpack --mode production --devtool hidden-source-map","test-compile": "tsc -p ./","test-watch": "tsc -watch -p ./","pretest": "npm run test-compile && npm run lint","lint": "eslint src --ext ts","test": "node ./out/test/runTest.js"},"devDependencies": {"@types/vscode": "^1.60.0","@types/glob": "^7.1.3","@types/mocha": "^8.2.2","@types/node": "14.x","eslint": "^7.27.0","@typescript-eslint/eslint-plugin": "^4.26.0","@typescript-eslint/parser": "^4.26.0","glob": "^7.1.7","mocha": "^8.4.0","typescript": "^4.3.2","vscode-test": "^1.5.2","ts-loader": "^9.2.2","webpack": "^5.38.1","webpack-cli": "^4.7.0"}
}

vscode插件的运行步骤

  • 注册onCommand激活事件,在输入命令后激活插件
  • 使用contributes.commands对命令行提供命令
  • 使用commands.registerCommand将一个函数绑定到命令上

4.获取token和注册publisher

必须具备token才能提交vscode插件至vscode商店中
注册地址
https://dev.azure.com

步骤一,注册微软账户

步骤二,登录后点击个人信息,创建新组织

步骤三, 点击人物头像,选择personal access token,选择所有组织,选择custom define,full access,生成token后记得保管,token忘记只能重新注册,无法找回

步骤四,注册成为publisher,需要科学上网,这一步我卡了半天,才反应过来

https://marketplace.visualstudio.com/manage/createpublisher?managePageRedirect=true

5.上传插件

上传插件全局命令

npm install -g vsce

想要上传vscode商店,需要进行开发者账户登录

vsce  login   你的publisher名

输入token

登陆成功后

vsce publish 你的插件版本号

注意:每一次提交的版本号都要跟以前的版本号不同,可以手动修改package.json里的版本号或者vsce publish patch自增版本号

如果你只想插件本地打包

vsce package

本地打包完成后生成visx文件,vscode插件中导入该visx文件,即可本地生效插件

vscode插件开发流程相关推荐

  1. vscode插件开发实践与demo源码

    vscode插件开发实践与demo源码 写在前面 工欲善其事必先利其器.vscode作为优秀的开发工具,给我的日常开发工作提供了极大的便利.其拓展机制更是如此. 但是,最近在做年度专业线任务时,有需要 ...

  2. VSCode插件开发全攻略(六)开发调试技巧

    更多文章请戳VSCode插件开发全攻略系列目录导航. 前言 在介绍完一些比较简单的内容点之后,我觉得有必要先和大家介绍一些开发中遇到的一些细节问题以及技巧,特别是后面一章节将要介绍WebView的知识 ...

  3. vs code 插件_[VSCode插件开发] 由浅入深,带你了解如何打造百万级产品

    去年,笔者有幸在微软技术暨生态大会上做了个演讲,主题是"从零开始开发一款属于你的 Visual Studio Code 插件". 演讲内容主要覆盖了VS Code插件开发的四个方面 ...

  4. VSCode插件开发全攻略

    原文:VSCode插件开发全攻略(一)概览 作者:小茗同学 文章索引 VSCode插件开发全攻略(一)概览 VSCode插件开发全攻略(二)HelloWord VSCode插件开发全攻略(三)pack ...

  5. WPS插件开发流程(2)

    上一篇文章WPS插件开发流程(1)中,我们详细讲了如何在Visual Studio中如何创建插件.在WPS中显示插件的方法.今天我们完成剩下的部分,讲解如何导出PIA.DLL强签名.打包安装文件夹的方 ...

  6. VSCode插件开发 国际化

    内容来源于:vscode 插件开发技巧:国际化 对于一个好的 vscode 插件,若不支持国际化委实可惜,本文介绍一种简单的 i18n 的做法,希望对各位插件开发者有所帮助.这里会从另一个大名鼎鼎的插 ...

  7. VSCode插件开发 浅谈workspace问题

    判断当前是否存在workspace 打开Settings, 有时可以看到这里有一个Workspace, 中文环境下叫做工作区. 什么时候会出现这个Workspace选项呢? 如果现在没有Workspa ...

  8. vscode 插件开发

    vscode 插件开发 文章目录 vscode 插件开发 [demo] menus when语句语法有很多,这里列举几个常用的: 组间排序 几个调试快捷键: 代码为什么没生效 打开文件 这是官网给出的 ...

  9. Fastadmin插件开发流程简要记录

    Fastadmin插件开发简易流程 Step1 使用命令行创建插件 Step2 更改插件信息 Step3 编辑插件相关数据库脚本 Step3 编辑插件的配置 Step4 为插件配置后台管理菜单 Ste ...

  10. VScode启动流程

    vscode使用electron架构,入口点在package.json中定义 说明入口文件在out/main.js,它对应的源文件在src/main.js,这两个文件是一样的(我也不知道原因,以后搞懂 ...

最新文章

  1. 11.3/11.4/11.5 MySQL安装
  2. 非名企非名校,我是如何入职顶级互联网公司的
  3. spring aop JointPoint类
  4. Android 性能优化——绘制优化
  5. grenndao 插入表数据报错
  6. 改变Oracle 默认显示格式
  7. 【CA】数字电视CA原理与破解方式
  8. 微信公众号添加html,微信公众号如何在文章里添加超链接的方法教程
  9. 集成建行聚合支付踩过的坑,有些槽不吐不快
  10. 中兴服务器bios启动顺序设置,bios设置启动图解教程
  11. 高手教你如何从零开始学游戏编程
  12. 计算机专业我的生涯规划档案,大学生学业生涯规划登记表11.doc
  13. OpenGL 驱动 与 扩展的关系
  14. s5pv210时钟系统详解
  15. 以太坊性能优化:分片技术、雷电网络、Casper-下一代以太坊共识协议
  16. 表格练习(工商银行电子汇款单)表单练习(用户注册)
  17. R语言︱SNA-社会关系网络—igraph包(中心度、中心势)(二)
  18. nginx作为web服务以及nginx.conf详解
  19. el-dialog对话框重新打开后数据遗留问题
  20. 双碳+24小时分时综合能源系统低碳优化调度(用Matlab+Yalmip+Cplex) 包含新能源消纳、热电联产、电锅炉、储能电池、天然气、碳捕集CCS、

热门文章

  1. ACM Plan UVa - 10102 The path in the colored field
  2. Ffplay源码read_thread解读(一)
  3. 前端用JS + SVG 实现关系图谱 流程图
  4. 【量化分析】债券投资分析
  5. 基于STM32c8t6的5路pwm占空比测量实验总结
  6. 一文搞懂 UndeclaredThrowableException
  7. [CTFHub] Web RCE Write ups
  8. Graphpad作图--百分比堆积柱形图
  9. 什么是自签名证书?自签名SSL证书的优缺点?
  10. wacom数位板怎么调压感_wacom手绘板_wacom手绘板的钢笔压力怎么设置?