How can I install Visual Studio Code extensions offline?

后端 未结 12 1207
终归单人心
终归单人心 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 10:03

    adding on to t3chb0t's answer, not sure why the option to download is not visible, so created a patch for those who use GreaseMonkey/ TamperMonkey: you can find the gist code here

    Or you can just paste the below lines in your browser console, and the link would magically appear:

    let version = document.querySelector('.ux-table-metadata > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > div:nth-child(1)').innerText
        , itemDetails = window.location.search.replace('?', '').split('&').filter(str => !str.indexOf('itemName')).map(str => str.split('=')[1])[0]
        , [author, extension] = itemDetails.split('.')
        , lAuthor = author.toLowerCase()
        , href = `https://${lAuthor}.gallery.vsassets.io:443/_apis/public/gallery/publisher/${author}/extension/${extension}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`
        , element = document.createElement('a');
    
    
    element.href = href;
    element.className = 'vscode-moreinformation dark';
    element.innerHTML = 'download .vsix file';
    element.download  = `${extension}.${version}.vsix`;
    document.querySelector('.vscode-install-info-container').appendChild(element);
    

提交回复
热议问题