Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ jobs:
workingDirectory: 'sample'
displayName: Build Sample

##### TSLint #####
- job: TSLint
displayName: 'TSLint'
pool:
vmImage: 'vs2017-win2016'
steps:
- task: NodeTool@0
inputs:
versionSpec: '12.x'
displayName: 'Install Node.js'
- bash: |
npm install -g tslint
tslint -c tslint.json 'dotnetcore-acquisition-library/src/**/*.ts' 'dotnetcore-acquisition-extension/src/**/*.ts'
displayName: Run Lint

##### Package and Publish #####
- job: Publish
displayName: 'Package and Publish'
Expand Down
6 changes: 6 additions & 0 deletions dotnetcore-acquisition-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dotnetcore-acquisition-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dotnetcore-acquisition-library": "file:../dotnetcore-acquisition-library"
},
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "5.2.6",
"@types/node": "12.0.0",
"@types/rimraf": "2.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as extension from '../../extension';
import * as chai from 'chai';
import { MockExtensionContext } from 'dotnetcore-acquisition-library';
import * as fs from 'fs';
import * as path from 'path';
import * as rimraf from 'rimraf';
import * as vscode from 'vscode';
import { MockExtensionContext } from 'dotnetcore-acquisition-library'
var assert = require('chai').assert;
import * as extension from '../../extension';
const assert = chai.assert;

suite('DotnetCoreAcquisitionExtension End to End', function () {
suite('DotnetCoreAcquisitionExtension End to End', function() {
const storagePath = path.join(__dirname, 'tmp');
const mockState = new MockExtensionContext();
const extensionPath = path.join(__dirname, '/../../..');
let context: vscode.ExtensionContext;

this.beforeAll(async function() {
this.beforeAll(async () => {
context = {
subscriptions: [],
globalStoragePath: storagePath,
globalState: mockState,
extensionPath: extensionPath
extensionPath,
} as any;
extension.activate(context);
});

this.afterEach(async function() {
this.afterEach(async () => {
// Tear down tmp storage for fresh run
await vscode.commands.executeCommand<string>('dotnet.uninstallAll');
rimraf.sync(storagePath);
Expand All @@ -40,15 +40,15 @@ suite('DotnetCoreAcquisitionExtension End to End', function () {
});

test('Install Command', async () => {
const version = '2.2'
const version = '2.2';
const dotnetPath = await vscode.commands.executeCommand<string>('dotnet.acquire', version);
assert.exists(dotnetPath);
assert.isTrue(fs.existsSync(dotnetPath!));
assert.include(dotnetPath, version);
}).timeout(20000);

test('Uninstall Command', async () => {
const version = '2.1'
const version = '2.1';
const dotnetPath = await vscode.commands.executeCommand<string>('dotnet.acquire', version);
assert.exists(dotnetPath);
assert.isTrue(fs.existsSync(dotnetPath!));
Expand All @@ -60,7 +60,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function () {
test('Install and Uninstall Multiple Versions', async () => {
const versions = ['1.1', '2.2', '1.0'];
let dotnetPaths: string[] = [];
for (var version of versions) {
for (const version of versions) {
const dotnetPath = await vscode.commands.executeCommand<string>('dotnet.acquire', version);
assert.exists(dotnetPath);
assert.include(dotnetPath, version);
Expand All @@ -69,8 +69,8 @@ suite('DotnetCoreAcquisitionExtension End to End', function () {
}
}
// All versions are still there after all installs are completed
for (let dotnetPath of dotnetPaths) {
for (const dotnetPath of dotnetPaths) {
assert.isTrue(fs.existsSync(dotnetPath));
}
}).timeout(40000);
});
});
9 changes: 4 additions & 5 deletions dotnetcore-acquisition-extension/src/test/functional/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
import * as Mocha from 'mocha';
import * as path from 'path';

export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd'
ui: 'tdd',
});
mocha.useColors(true);

Expand Down Expand Up @@ -39,4 +38,4 @@ export function run(): Promise<void> {
}
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ async function main() {
}
}

main();
main();
9 changes: 9 additions & 0 deletions dotnetcore-acquisition-library/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dotnetcore-acquisition-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"devDependencies": {
"@types/chai": "^4.2.4",
"@types/chai-as-promised": "^7.1.2",
"@types/mocha": "5.2.6",
"@types/node": "12.0.0",
"@types/request-promise-native": "^1.0.17",
Expand Down
31 changes: 16 additions & 15 deletions dotnetcore-acquisition-library/src/AcquisitionInvoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,10 @@ import { IDotnetInstallationContext } from './IDotnetInstallationContext';

export class AcquisitionInvoker extends IAcquisitionInvoker {
private scriptPath: string;

constructor(scriptPath: string, eventStream: IEventStream) {
super(eventStream);
this.scriptPath = path.join(scriptPath, 'node_modules', 'dotnetcore-acquisition-library', 'install scripts', 'dotnet-install' + this.getScriptEnding());
}

private getInstallCommand(version: string, dotnetInstallDir: string): string {
const args = [
'-InstallDir', `'${dotnetInstallDir}'`, // Use single quotes instead of double quotes (see https://github.com/dotnet/cli/issues/11521)
'-Runtime', 'dotnet',
'-Version', version,
];

return `"${this.scriptPath}" ${args.join(' ')}`;
}
private getScriptEnding(): string {
return os.platform() === 'win32' ? '.cmd' : '.sh';
this.scriptPath = path.join(scriptPath, 'node_modules', 'dotnetcore-acquisition-library', 'install scripts', `dotnet-install${this.getScriptEnding()}`);
}

public installDotnet(installContext: IDotnetInstallationContext): Promise<void> {
Expand All @@ -59,4 +46,18 @@ export class AcquisitionInvoker extends IAcquisitionInvoker {
}
});
}

private getInstallCommand(version: string, dotnetInstallDir: string): string {
const args = [
'-InstallDir', `'${dotnetInstallDir}'`, // Use single quotes instead of double quotes (see https://github.com/dotnet/cli/issues/11521)
'-Runtime', 'dotnet',
'-Version', version,
];

return `"${this.scriptPath}" ${args.join(' ')}`;
}

private getScriptEnding(): string {
return os.platform() === 'win32' ? '.cmd' : '.sh';
}
}
28 changes: 16 additions & 12 deletions dotnetcore-acquisition-library/src/DotnetCoreAcquisitionWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import * as path from 'path';
import rimraf = require('rimraf');
import { Memento } from 'vscode';
import { IEventStream } from './EventStream';
import { DotnetAcquisitionStarted, DotnetUninstallAllStarted, DotnetUninstallAllCompleted } from './EventStreamEvents';
import {
DotnetAcquisitionStarted,
DotnetUninstallAllCompleted,
DotnetUninstallAllStarted,
} from './EventStreamEvents';
import { IAcquisitionInvoker } from './IAcquisitionInvoker';
import { IDotnetInstallationContext } from './IDotnetInstallationContext';
import { IVersionResolver } from './IVersionResolver';
Expand All @@ -22,10 +26,10 @@ export class DotnetCoreAcquisitionWorker {
private acquisitionPromises: { [version: string]: Promise<string> | undefined };

constructor(private readonly storagePath: string,
private readonly extensionState: Memento,
private readonly eventStream: IEventStream,
private readonly acquisitionInvoker: IAcquisitionInvoker,
private readonly versionResolver: IVersionResolver) {
private readonly extensionState: Memento,
private readonly eventStream: IEventStream,
private readonly acquisitionInvoker: IAcquisitionInvoker,
private readonly versionResolver: IVersionResolver) {
this.installDir = path.join(this.storagePath, '.dotnet');
const dotnetExtension = os.platform() === 'win32' ? '.exe' : '';
this.dotnetExecutable = `dotnet${dotnetExtension}`;
Expand All @@ -40,12 +44,12 @@ export class DotnetCoreAcquisitionWorker {
rimraf.sync(this.installDir);

await this.extensionState.update(this.installingVersionsKey, []);

this.eventStream.post(new DotnetUninstallAllCompleted());
}

public async acquire(version: string): Promise<string> {
version = await this.versionResolver.getFullVersion(version);
version = await this.versionResolver.getFullVersion(version);

const existingAcquisitionPromise = this.acquisitionPromises[version];
if (existingAcquisitionPromise) {
Expand All @@ -57,7 +61,7 @@ export class DotnetCoreAcquisitionWorker {

const acquisitionPromise = this.acquireCore(version).catch((error: Error) => {
delete this.acquisitionPromises[version];
throw new Error('Dotnet Core Acquisition Failed: ' + error.message);
throw new Error(`Dotnet Core Acquisition Failed: ${error.message}`);
});

this.acquisitionPromises[version] = acquisitionPromise;
Expand Down Expand Up @@ -88,8 +92,8 @@ export class DotnetCoreAcquisitionWorker {

const installContext = {
installDir: dotnetInstallDir,
version: version,
dotnetPath: dotnetPath
version,
dotnetPath,
} as IDotnetInstallationContext;
this.eventStream.post(new DotnetAcquisitionStarted(version));
await this.acquisitionInvoker.installDotnet(installContext);
Expand All @@ -105,7 +109,7 @@ export class DotnetCoreAcquisitionWorker {

return dotnetPath;
}

private async uninstall(version: string) {
delete this.acquisitionPromises[version];

Expand All @@ -121,7 +125,7 @@ export class DotnetCoreAcquisitionWorker {
}

private getDotnetInstallDir(version: string) {
const dotnetInstallDir = path.join(this.installDir, version)
const dotnetInstallDir = path.join(this.installDir, version);
return dotnetInstallDir;
}
}
Loading