How to install Visual Studio Code extensions behind proxy

I have had the pleasure to download Visual Studio Code and extensions in a new corporate environment recently. Like usual it was a struggle. Took me a while but eventually I got it done.

Downloading and installing VS Code was fine as I had internet access and local admin rights. You can pretty much stop reading if your corporate environment is so locked down that you can’t even install software. No point going any further, just go find another job.

Once I have installed VS Code, I looked for the powershell extension. To my surprise (well, not really surprised), I was presented with an error message:

getaddrinfo ENOTFOUND marketplace.visualstudio.com marketplace.visualstudio.com:443

A search in Google returned two very useful links. Here they are to save you the trouble:

https://github.com/Microsoft/vscode/issues/69
http://blog.majcica.com/2016/04/07/visual-studio-code-behind-a-proxy/

In a nutshell, the solution involved two steps:

  1. Find the proxy settings.
  2. Overwrite VS Code default settings.

Find the proxy settings

  1. Goto internet explorer -> Internet options -> Connections -> LAN settings
  2. If proxy server is populated, then take settings from here. If not, then read on.
  3. In my environment, there was an automatic configuration script BUT it was grayed out. That means I could neither read the whole string nor copy it out.
  4. In order to read the full url, I needed to go to the registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
  5. Copy the value from AutoConfigURL and open it in IE. I was prompted to download a .pac file.
  6. You should then be able to find the proxy settings within the file.

Overwrite VS Code default settings

  1. In VS Code, goto File -> Preferences -> User Settings
  2. Paste the proxy settings on the right hand side where it says settings.json
    // Place your settings in this file to overwrite the default settings
    {
     "http.proxy": "http://xxx.xxx.xxx:80",
     "https.proxy": "https://xxx.xxx.xxx:80",
     "http.proxyStrictSSL": false
    }

    vscode_user_settings

  3. Restart VS Code.
  4. This time you should be able to see the extensions available in the market place.vscode_extensions

Now I can go back and do some real work.