Is there a way to change the extensions folder location for Visual Studio Code?

半腔热情 提交于 2021-02-17 07:42:15

问题


I've put Visual Studio Code on OneDrive, for the purpose of syncing it with its settings across my devices.

However, extensions are stored in %USERPROFILE%\.vscode\extensions on Windows.

Is it possible to change this folder's location so I can put it in the main Visual Studio Code folder?

At first I thought that copying the extensions in the resources\app\extensions of Visual Studio Code folder will be a nice workaround, but that doesn't work.

I've also searched for a solution on the documentation page and in the user settings, with no results.


回答1:


A little hack:

Create a symbolic link to the folder %USERPROFILE%\.vscode\extensions under the Visual Studio Code install path.




回答2:


What I did - after installing Visual Studio Code for the first time, I checked the documentation and added at the end of 'Target' field of editor's shortcut the following (there's a space before the two dashes):

 --extensions-dir="DRIVELETTER:\VSCODE\extensions"
 --user-data-dir="DRIVELETTER:\VSCODE\settings"

where DRIVERLETTER and VSCODE are the corresponding drive and directory where Visual Studio Code is installed. So mine looks like this:

"D:\Microsoft VS Code\Code.exe" --extensions-dir="D:\Microsoft VS Code\extensions"

Here is for the user data directory:

"D:\Microsoft VS Code\Code.exe" --user-data-dir="D:\Microsoft VS Code\settings"

Accessing the 'Target' field is done by right-clicking the shortcut and choosing 'Properties'

Anyway, there's a simpler solution to that problem - just use the portable version of Visual Studio Code. It works under Windows, Linux, and macOS:

Enable Portable Mode

Windows and Linux

After unzipping the Visual Studio Code download, simply create a data folder within Visual Studio 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 Visual Studio Code data, including session state, preferences, extensions, etc.

The data folder can be moved to other Visual Studio Code installations. This is useful for updating your portable Visual Studio Code version: simply move the data folder to a newer extracted version of Visual Studio 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 Visual Studio 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.




回答3:


https://code.visualstudio.com/docs/editor/extension-gallery


code --extensions-dir 'new_directory_to_set'

Set the root path for extensions.




回答4:


Follow the below steps for changing the extension path in VS.

  1. Set "code" path in environment variable.

    path = VS_CODE_INSTALL_DIRECTORY/bin;
    
  2. Open VS , in VS terminal execute the below command.

    code --extensions-dir "new_directory_path"
    
  3. Install the required extension.

All Done.

Note:Dont forget to vote the answer



来源:https://stackoverflow.com/questions/40080793/is-there-a-way-to-change-the-extensions-folder-location-for-visual-studio-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!