Skip to content
This repository has been archived by the owner on Sep 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #144 from joaocgreis/joaocgreis-I9C
Browse files Browse the repository at this point in the history
VS Installation Improvements
  • Loading branch information
felixrieseberg authored Sep 18, 2018
2 parents 4420dc8 + 698d86c commit e02b4ba
Show file tree
Hide file tree
Showing 11 changed files with 4,160 additions and 27 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ file a bug.

## Visual Studio 2017 vs Visual Studio 2015
This module is capable of installing either the build tools from Visual Studio [2017](https://blogs.msdn.microsoft.com/vcblog/2016/11/16/introducing-the-visual-studio-build-tools/) or Visual
Studio [2015](https://blogs.msdn.microsoft.com/vcblog/2016/03/31/announcing-the-official-release-of-the-visual-c-build-tools-2015/). Since Node's underlying build tools still don't fully support 2017, you might
have a better experience with 2015 - even if it sounds a bit outdated. On the other hand, if
you are only trying to compile a certain set of modules, the 2017 build tools are smaller and
install a bit quicker.
Studio [2015](https://blogs.msdn.microsoft.com/vcblog/2016/03/31/announcing-the-official-release-of-the-visual-c-build-tools-2015/).

By default, this tool will install the 2015 build tools. To change that, run this script with
the `--vs2017` parameter.
By default, this tool will install the 2017 build tools. To change that, run this script with
the `--vs2015` parameter.

## Usage

```
npm [--python-mirror=''] [--proxy=''] [--debug] [--strict-ssl] [--resume] [--sockets=5] [--vcc-build-tools-parameters=''] [--vs2017] [--dry-run-only] install --global windows-build-tools
npm [--python-mirror=''] [--proxy=''] [--debug] [--strict-ssl] [--resume] [--sockets=5] [--vcc-build-tools-parameters=''] [--vs2015] [--dry-run-only] install --global windows-build-tools
```

Optional arguments:
Expand All @@ -54,7 +51,7 @@ Optional arguments:
* `--sockets`: Specifies the number of http sockets to use at once (this controls concurrency). Defaults to infinity.
* `--vcc-build-tools-parameters`: Specifies additional parameters for the Visual C++ Build Tools 2015. See below for more detailed usage instructions.
* `--silent`: The script will not output any information.
* `--vs2017`: Install the Visual Studio 2017 Build Tools instead of the Visual Studio 2015 ones.
* `--vs2015`: Install the Visual Studio 2015 Build Tools instead of the Visual Studio 2017 ones.
* `--dry-run-only`: Don't actually do anything, just print what the script would have done.

## Supplying Parameters to the VCC Build Tools
Expand All @@ -71,6 +68,8 @@ npm --vcc-build-tools-parameters='[""--allWorkloads""]' install --global windows

### Visual Studio 2015 Parameters

If you run `windows-build-tools` with `--vs2015`, these parameters are available:

- `/AdminFile`: <filename> Specifies the installation control file.
- `/CreateAdminFile`: <filename> Specifies the location to create a control file that can then be used
- `/CustomInstallPath`: <path> Set Custom install location.
Expand All @@ -91,7 +90,7 @@ npm --vcc-build-tools-parameters='[""--allWorkloads""]' install --global windows

### Visual Studio 2017 Parameters

If you run `windows-build-tools` with `--vs2017`, the available parameters [are documented here](https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio).
The available parameters [are documented here](https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio).

### Offline Installation

Expand Down
4 changes: 4 additions & 0 deletions __tests__/utils/get-build-tools-installer-path-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jest.mock('../../src/utils/get-is-python-installed', () => ({

describe('getBuildToolsInstallerPath', () => {
it('gets the correct information (2015)', () => {
process.env.npm_config_vs2015 = 'true';

const { getBuildToolsInstallerPath } = require('../../src/utils/get-build-tools-installer-path');

expect(getBuildToolsInstallerPath()).toEqual({
Expand All @@ -17,6 +19,8 @@ describe('getBuildToolsInstallerPath', () => {
path: 'C:\\workDir\\BuildTools_Full.exe',
url: 'https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe',
});

delete process.env.npm_config_vs2015;
});

it('gets the correct information (2017)', () => {
Expand Down
46 changes: 40 additions & 6 deletions __tests__/utils/installation-success-test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as fs from 'fs-extra';
import { includesFailure, includesSuccess } from '../../src/utils/installation-sucess';

jest.mock('../../src/constants', () => ({
BUILD_TOOLS: { version: 2015 }
}));

describe('installation-success', () => {
describe('includesSuccess', () => {
const { includesSuccess } = require('../../src/utils/installation-sucess');

it('correctly reports success', () => {
expect(includesSuccess('Variable: IsInstalled = 1')).toEqual({
isBuildToolsSuccess: true,
Expand All @@ -23,11 +24,6 @@ describe('installation-success', () => {
isPythonSuccess: false
});

expect(includesSuccess('Setting string variable \'IsInstalled\' to value \'1\'')).toEqual({
isBuildToolsSuccess: true,
isPythonSuccess: false
});

expect(includesSuccess('Blubblub')).toEqual({
isBuildToolsSuccess: false,
isPythonSuccess: false
Expand All @@ -51,6 +47,8 @@ describe('installation-success', () => {
});

describe('includesFailure', () => {
const { includesFailure } = require('../../src/utils/installation-sucess');

it('correctly reports failure for build tools', () => {
expect(includesFailure('Closing installer. Return code: -13')).toEqual({
isBuildToolsFailure: true,
Expand All @@ -70,4 +68,40 @@ describe('installation-success', () => {
});
});
});

describe('VS log files', () => {
function testLog(file, installEndLine, success, vsVersion) {
// file must end in .txt because .log is gitignored
// installEndLine is the first line (zero based) of the last block of timestamps,
// it should point to the moment the installer starts cleaning up.

jest.setMock('../../src/constants', {
BUILD_TOOLS: { version: vsVersion }
});
jest.resetModules();
const { includesSuccess, includesFailure } = require('../../src/utils/installation-sucess');

const finalText = fs.readFileSync(`${__dirname}/logfiles/${file}.txt`, 'utf8');
const installingText = finalText.split(/\r?\n/).slice(0, installEndLine).join('\n');

expect(includesSuccess(installingText).isBuildToolsSuccess).toEqual(false);
expect(includesFailure(installingText).isBuildToolsFailure).toEqual(false);

if (success) {
expect(includesSuccess(finalText).isBuildToolsSuccess).toEqual(true);
// Don't check failure, it can be true in case of success.
} else {
expect(includesSuccess(finalText).isBuildToolsSuccess).toEqual(false);
expect(includesFailure(finalText).isBuildToolsFailure).toEqual(true);
}
}

it('VS2015 successful intallation', () => {
testLog('vs2015-success', 3494, true, 2015);
});

it('VS2017 successful intallation', () => {
testLog('vs2017-success', 75, true, 2017);
});
});
});
Loading

0 comments on commit e02b4ba

Please sign in to comment.