我已将VSCode放在OneDrive上,目的是将其与我的设备上的设置同步。
但是,扩展程序存储在Windows上的%USERPROFILE%\.vscode\extensions
中。
是否可以更改此文件夹的位置,以便将其放在主VSCode文件夹中?
起初我虽然复制VSCode文件夹的resources\app\extensions
中的扩展名将是一个很好的解决方法,但这不起作用。
我还在documentation page和用户设置中搜索了一个没有结果的解决方案。
答案 0 :(得分:11)
一点点破解:
在Visual Studio代码安装路径下创建指向文件夹%USERPROFILE%\.vscode\extensions
的符号链接。
答案 1 :(得分:8)
我所做的-首次安装VSCode之后,我检查了文档,并在编辑器快捷方式的“目标”字段的末尾添加了以下内容(两个破折号前有一个空格):
--extensions-dir="DRIVELETTER:\VSCODE\extensions"
--user-data-dir="DRIVELETTER:\VSCODE\settings"
其中DRIVERLETTER和VSCODE是安装VSCode的相应驱动器和目录。我的看起来像这样:
"D:\Microsoft VS Code\Code.exe" --extensions-dir="D:\Microsoft VS Code\extensions"
编辑:这是用户数据目录,并且是这样:
"D:\Microsoft VS Code\Code.exe" --user-data-dir="D:\Microsoft VS Code\settings"
通过右键单击快捷方式并选择“属性”来访问“目标”字段
编辑#2:无论如何,有一个更简单的解决方案-使用VS Code的可移植版本。它可以在Windows,Linux,macOS下运行:
Enable Portable Mode
Windows, Linux
After unzipping the VS Code download, simply create a data folder within Code's folder:
|- VSCode-win32-x64-1.25.0-insider
| |- Code.exe (or code executable)
| |- data
| |- ...
From then on, that folder will be used to contain all Code data, including session state, preferences, extensions, etc.
The data folder can be moved to other VS Code installations. This is useful for updating your portable Code version: simply move the data folder to a newer extracted version of VS Code.
macOS
On macOS, you need to place the data folder as a sibling of the application itself. Since the folder will be alongside the application, you need to name it specifically so that Code can find it. The default folder name is code-portable-data:
|- Visual Studio Code.app
|- code-portable-data
Portable Mode won't work if your application is in quarantine, which happens by default if you just downloaded Code. Make sure you remove the quarantine attribute, if Portable Mode doesn't seem to work:
xattr -dr com.apple.quarantine Visual\ Studio\ Code.app
**Note**: On Insiders, the folder should be named code-insiders-portable-data
答案 2 :(得分:1)
https://code.visualstudio.com/docs/editor/extension-gallery
code --extensions-dir 'new_directory_to_set'
设置扩展的根路径。
答案 3 :(得分:1)
请按照以下步骤在VS中更改扩展路径。
在环境变量中设置“代码”路径。
path = VS_CODE_INSTALL_DIRECTORY/bin;
打开VS,在VS终端中执行以下命令。
code --extensions-dir "new_directory_path"
- 安装所需的扩展程序。
全部完成。
注意:请不要忘记投票答案