参考博客
- GitHub-vscode里的Packaging部分:https://github.com/microsoft/vscode/wiki/How-to-Contribute 这里提供了vscode打包后可以发布的平台代码:
win32-ia32 | win32-x64 | darwin-x64 | darwin-arm64 | linux-ia32 | linux-x64 | linux-arm |
---|
基础打包命令:yarn gulp vscode-linux-x64
,不同平台替换平台代码即可。
- 解决报错digital envelope routines::unsupported:https://blog.csdn.net/itopit/article/details/127280592
前期准备
- gulp:前端自动化打包构建工具,基于流格式的打包构建工具
使用如下命令可以查看gulp所能执行的任务:gulp --tasks
vscode源码打包为exe文件
打包vscode只需要一行命令即可,但是在初次执行时报错,解决报错花费2个小时。
进入vscode源码文件夹下,在命令行中执行
yarn gulp vscode-win32-x64
或者执行
yarn gulp vscode-win32-x64-min
上述两种方式都可以打包vscode源码,带min参数后会对文件进行压缩。实际测试两种打包方式产生的文件所占用空间:
初次运行上述代码打包vscode源码时报错:digital envelope routines::unsupported。报错原因是新版本node.js中的OpenSSL3.0对允许算法和密钥大小增加了严格的限制。
查看node.js版本:node --version
,显示:v18.14.0
报错解决方式:
- 修改package.json文件
打开vscode源码文件夹下的package.json文件,在"scripts":
标签开头添加:
"serve": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service serve",
"build": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build",
"build:report": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build --report",
添加后"scripts":
标签下内容如下(下面还有很多,没有都复制过来):
"scripts": {
"serve": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service serve",
"build": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build",
"build:report": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build --report",
"test": "echo Please run any of the test scripts from the scripts folder.",
"test-browser": "npx playwright install && node test/unit/browser/index.js",
"test-browser-no-install": "node test/unit/browser/index.js",
- 添加环境变量
在系统变量里添加环境变量:
变量名(N) | 变量值(V) |
---|
NODE_OPTIONS | –openssl-legacy-provider |
添加环境变量后,重启电脑,重新执行yarn gulp vscode-win32-x64
即可,打包后的文件夹出现在vscode同级目录中。
打包后是一个文件夹,进入文件夹有一个Code - OSS.exe
,双击此文件即可运行出VSCode。【绿色免安装式的软件】
将VSCode打包为可安装文件(非绿色免安装式)
这里在官网上没有找到介绍,根据gulp --tasks
命令尝试得到的结果。
在上述步骤的基础上(已生成VSCode绿色免安装版),将VSCode打包为可安装文件。
进入vscode源码文件夹下,执行如下代码创建VSCode升级更新程序。
yarn gulp vscode-win32-x64-inno-updater
接着,执行如下代码,创建可安装文件:
yarn gulp vscode-win32-x64-user-setup
执行完毕会在vscode源码文件夹\.build\win32-x64\user-setup
目录下出现VSCodeSetup.exe安装文件,双击即可安装。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)