How can I install Visual Studio Code extensions offline?

后端 未结 12 1214
终归单人心
终归单人心 2020-11-27 09:12

I have installed Visual Studio Code on a machine that is not, and cannot be, connected to the Internet. According to the documentation, I can install an extension from the c

12条回答
  •  无人及你
    2020-11-27 09:49

    UPDATE 2017-12-13

    You can now download the extension directly from the marketplace.

    As of Visual Studio Code 1.7.1 dragging or opening the extension does not work any more. In order to install it manually you need to:

    • open the extensions sidebar
    • click on the ellipsis in the right upper corner
    • choose Install from VSIX


    Old Method

    According to the documentation it is possible to download an extension directly:

    An extension's direct download URL is in the form:

    https://${publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${publisher}/extension/${extension name}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage
    

    This means that in order to download the extension you need to know

    • the publisher name
    • the version
    • the extension name

    You can find all this information in the URL.

    Example

    Here's an example for downloading an installing the C# v1.3.0 extension:

    Publisher, Extension and Version

    You can find the publisher and the extension names on the extension's homepage inside its URL:

    https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

    Here the publisher is ms-vscode and the extension name is csharp.

    The version can be found on the right side in the More Info area.

    To download it you need to create a link from the template above:

    https://ms-vscode.gallery.vsassets.io/_apis/public/gallery/publisher/ms-vscode/extension/csharp/1.3.0/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage

    All packages will have the same name Microsoft.VisualStudio.Services.VSIXPackage, so you'll need to rename it after downloading if you want to know what package it was later.

    Installation

    In order to install the extension

    • Rename the file and give it the *.vsix extension
    • Open Visual Studio Code, go to menu FileOpen File... or Ctrl + O and select the .vsix file
    • If everything went fine, you should see this message at the top of the window:

    Extension was successfully installed. Restart to enable it.

提交回复
热议问题