Install Visual Studio Code OSS to Debian Wheezy


|Playing with Debian Wheezy|URL|
|:--|:--|
|Atom|http://qiita.com/cielavenir/items/7835e3d110d7ad79c407|
|VSCode OSS|http://qiita.com/cielavenir/items/8eb3f57373bac0f10d6f|
|Skype|http://qiita.com/cielavenir/items/1b1d733e4ede8593040f|
|Meshlab 2016|http://qiita.com/cielavenir/items/5e02ce18d162e17c8859|

Visual Studio Code provides debian package, but it requires libc6 >=2.15, which is not the case of Debian Wheezy. So we have to compile it from the source code.

## Shorter way

- Go to https://www.dropbox.com/sh/g9ky5opxbiey60t/AADqD8v5Yc_quPvk9VRKtgVSa debian code-oss_1.14.2.deb

## 170724
- Uploaded 1.14.2 binary
- Since migrating to Stretch is planned, this will be my final binary upload.

## 170718
- Uploaded 1.14.1 binary
- This build enables MarketPlace (see below).
- To fix build: I have done:
    1. To fix `ECONNRESET 191.238.172.191:443` issue, I removed ms-vscode.node-debug(2) from build/gulpfile.vscode.js. Please install from MarketPlace.
        - https://github.com/Microsoft/vscode/issues/29487
    1. In `extensions/vscode-api-tests/src/workspace.test.ts`, I disabled findFiles test to deal with `Property 'timeout' does not exist on type 'ITest'` issue.

## 170627
- Uploaded 1.13.1 binary

## 170605
- I saw NODE_MODULE_VERSION issue.
- electron-rebuild *might* be required.

```
sudo npm install electron-rebuild -g
electron-rebuild

./scripts/npm.sh install --arch=x64
node --max_old_space_size=2048 /usr/bin/gulp vscode-linux-x64
node --max_old_space_size=2048 /usr/bin/gulp vscode-linux-x64-build-deb
```

## Prerequisites
- nodejs (unlike [the case of atom](http://qiita.com/cielavenir/items/7835e3d110d7ad79c407), clang-3.4 is not required maybe?)
- https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
- gulp is also required.

```
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -/
sudo apt-get update
sudo apt-get install nodejs
sudo npm install gulp -g # for packaging
```

## Building

```
git clone https://github.com/Microsoft/vscode
cd vscode
git tag
git checkout 1.14.1 # use the latest "release" from git tag
./scripts/npm.sh install --arch=x64
node --max_old_space_size=2048 /usr/bin/gulp vscode-linux-x64
node --max_old_space_size=2048 /usr/bin/gulp vscode-linux-x64-build-deb
sudo dpkg -i .build/linux/deb/amd64/deb/code-oss*.deb
```

## Extensions

### Newer way

- In building, add this snippet to `product.json`.

```json
"extensionsGallery": {
    "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
    "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
    "itemUrl": "https://marketplace.visualstudio.com/items"
}
```

- For existing installation, edit `/usr/share/code-oss/resources/app/product.json`.
- Acknowledgements: https://github.com/Microsoft/vscode/issues/23831

### Older (primitive) way

- Since this is the OSS version, Extension Marketplace is disabled.
- You have to install extentions manually.

1. Search for the extension in marketplace ( https://marketplace.visualstudio.com/ )
2. Convert the URI ( https://marketplace.visualstudio.com/items?itemName=... ) and version to file URI (use a small Ruby (1.9 compatible) script below)
3. Download the file
4. Install it via `code-oss --install-extension file.vsix`

```rb:show_vsix_uri.rb
#!/usr/bin/ruby
#acknowledgement: http://www.usagi1975.com/26jan171624/
#after downloading the specified URI, use: code --install-extension
require 'uri'
require 'net/http'
require 'json'
uri=URI.parse(ARGV[0])
http=Net::HTTP.new(uri.host,uri.port)
http.use_ssl=true
json=http.start{
  resp=http.get(uri.path+'?'+uri.query)
  JSON.parse(resp.body.split('<script class="vss-extension"')[1].split('</script>')[0].split('>')[1])
}
puts "wget -O #{json['extensionName']}_#{json['versions'][0]['version']}.vsix https://#{json['publisher']['publisherName']}.gallery.vsassets.io/_apis/public/gallery/publisher/#{json['publisher']['publisherName']}/extension/#{json['extensionName']}/#{json['versions'][0]['version']}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"
```