DEV Community

codemee
codemee

Posted on • Edited on

6 2

製作可攜式版本的 Visual Studio Code

下載 Visual Studio Code 的時候會有 zip 格式的選項可以選擇, 不過如果你只是單純下載後解開, 它並不是真正的可攜式版本, 不論是設定檔案還是你安裝的延伸套件都還是會放在使用者自己的資料夾中。如果想要製作一個真正可攜的 vscode, 只要在解開的資料夾中建立一個 data 資料夾即可, 這樣所有跟 vscode 相關的檔案都會放在這個 data 資料夾下, 像是這樣:



VSCODE
├─bin
├─data
│  ├─extensions
│  │  ├─ms-python.vscode-pylance-2022.6.10
│  │  ├─...
│  │  └─ms-vscode.cpptools-themes-1.0.0
│  └─user-data
│      ├─Backups
│      ├─...
│      └─Workspaces
├─locales
├─policies
│  └─en-US
├─resources
│  └─app
├─swiftshader
└─tools


Enter fullscreen mode Exit fullscreen mode

這樣只要將整個 vscode 資料夾複製起來, 就可以移到其他機器上使用, 甚至可以在同一台機器上建置不同的 vscode 環境使用。

以上的用法適用於 Windows 與 Linux, 如果是 Mac, 請參照官方說明文件

執行 bin 資料夾下的 code.cmd

要注意的是, 如果你直接執行 vscode 資料夾下的 code.exe, 會噴出一大堆的訊息, 像是這樣:

請改成執行 bin 資料夾下的 code.cmd 批次檔, 它會幫你加上必要的參數, 就不會噴出你不需要觀看的訊息了。如果要在 path 環境變數加入 vscode 的路徑, 也請記得要加入的是 bin 資料夾的路徑。

升級版本

可攜式 vscode 一樣會在有新版本的時候通知你:

但是按下連結後並不會自動幫你更新, 而是直接帶你下載新版本的 zip 格式檔案, 你必須自己下載新的版本, 然後解開覆蓋掉舊版本的資料夾。或者你也可以解開新的版本, 將原本的 data 資料夾複製過去。

如果是 Mac, 官方文件說明一樣會自動更新。

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay