Skip to content

Commit ad8fea9

Browse files
authored
Merge pull request #2707 from akshita31/installLock
Use a separate install.Lock for each dependency
2 parents cab094a + 686b9ba commit ad8fea9

File tree

14 files changed

+2210
-2421
lines changed

14 files changed

+2210
-2421
lines changed

package-lock.json

Lines changed: 2101 additions & 2340 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"minimist": "1.2.0",
128128
"mocha": "5.0.4",
129129
"mocha-typescript": "1.1.12",
130+
"mock-fs": "^4.7.0",
130131
"mock-http-server": "0.2.0",
131132
"npm-run-all": "4.1.2",
132133
"nyc": "11.8.0",
@@ -140,10 +141,11 @@
140141
"typescript": "2.8.3",
141142
"unzip2": "0.2.5",
142143
"vsce": "1.40.0",
143-
"vscode": "1.1.18"
144+
"vscode": "^1.1.21"
144145
},
145146
"runtimeDependencies": [
146147
{
148+
"id": "OmniSharp",
147149
"description": "OmniSharp for Windows (.NET 4.6 / x86)",
148150
"url": "https://download.visualstudio.microsoft.com/download/pr/515dbb33-d644-4ba6-9ee4-8ca7227ab580/02621f196a581cb3062dbeab2ec28429/omnisharp-win-x86-1.32.8.zip",
149151
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x86-1.32.8.zip",
@@ -158,6 +160,7 @@
158160
"platformId": "win-x86"
159161
},
160162
{
163+
"id": "OmniSharp",
161164
"description": "OmniSharp for Windows (.NET 4.6 / x64)",
162165
"url": "https://download.visualstudio.microsoft.com/download/pr/515dbb33-d644-4ba6-9ee4-8ca7227ab580/bdfde5788994e381c9a3efe5777081bd/omnisharp-win-x64-1.32.8.zip",
163166
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x64-1.32.8.zip",
@@ -172,6 +175,7 @@
172175
"platformId": "win-x64"
173176
},
174177
{
178+
"id": "OmniSharp",
175179
"description": "OmniSharp for OSX",
176180
"url": "https://download.visualstudio.microsoft.com/download/pr/515dbb33-d644-4ba6-9ee4-8ca7227ab580/dcead54f3e2dcc736d0ca1cbfde2ad0c/omnisharp-osx-1.32.8.zip",
177181
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-osx-1.32.8.zip",
@@ -187,6 +191,7 @@
187191
"platformId": "osx"
188192
},
189193
{
194+
"id": "OmniSharp",
190195
"description": "OmniSharp for Linux (x86)",
191196
"url": "https://download.visualstudio.microsoft.com/download/pr/515dbb33-d644-4ba6-9ee4-8ca7227ab580/ac9dde43e4905a8481c35f557fe09502/omnisharp-linux-x86-1.32.8.zip",
192197
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x86-1.32.8.zip",
@@ -206,6 +211,7 @@
206211
"platformId": "linux-x86"
207212
},
208213
{
214+
"id": "OmniSharp",
209215
"description": "OmniSharp for Linux (x64)",
210216
"url": "https://download.visualstudio.microsoft.com/download/pr/515dbb33-d644-4ba6-9ee4-8ca7227ab580/ee3801c7083438b5e54fa7405662565a/omnisharp-linux-x64-1.32.8.zip",
211217
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x64-1.32.8.zip",
@@ -224,6 +230,7 @@
224230
"platformId": "linux-x64"
225231
},
226232
{
233+
"id": "Debugger",
227234
"description": ".NET Core Debugger (Windows / x64)",
228235
"url": "https://download.visualstudio.microsoft.com/download/pr/90e2038c-960d-4018-924e-30f520f887ab/117523c7024fbf6ffef530b707d7253a/coreclr-debug-win7-x64.zip",
229236
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-17-1/coreclr-debug-win7-x64.zip",
@@ -237,6 +244,7 @@
237244
"installTestPath": "./.debugger/vsdbg-ui.exe"
238245
},
239246
{
247+
"id": "Debugger",
240248
"description": ".NET Core Debugger (macOS / x64)",
241249
"url": "https://download.visualstudio.microsoft.com/download/pr/90e2038c-960d-4018-924e-30f520f887ab/2d53db027d1e67b899a7f083800b2bd4/coreclr-debug-osx-x64.zip",
242250
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-17-1/coreclr-debug-osx-x64.zip",
@@ -254,6 +262,7 @@
254262
"installTestPath": "./.debugger/vsdbg-ui"
255263
},
256264
{
265+
"id": "Debugger",
257266
"description": ".NET Core Debugger (linux / x64)",
258267
"url": "https://download.visualstudio.microsoft.com/download/pr/90e2038c-960d-4018-924e-30f520f887ab/090d7ebd63a3d44b31cb23568b53833d/coreclr-debug-linux-x64.zip",
259268
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-17-1/coreclr-debug-linux-x64.zip",
@@ -271,6 +280,7 @@
271280
"installTestPath": "./.debugger/vsdbg-ui"
272281
},
273282
{
283+
"id": "Razor",
274284
"description": "Razor Language Server (Windows / x64)",
275285
"url": "https://download.visualstudio.microsoft.com/download/pr/3b0ae709-c067-48b4-a658-549ca972e437/bbd021dbeab477395f37f1c4e39c31ad/razorlanguageserver-win-x64-1.0.0-alpha2-20181112.3.zip",
276286
"installPath": ".razor",
@@ -282,6 +292,7 @@
282292
]
283293
},
284294
{
295+
"id": "Razor",
285296
"description": "Razor Language Server (Windows / x86)",
286297
"url": "https://download.visualstudio.microsoft.com/download/pr/3b0ae709-c067-48b4-a658-549ca972e437/d4196db447b32b655910532321f4bd6a/razorlanguageserver-win-x86-1.0.0-alpha2-20181112.3.zip",
287298
"installPath": ".razor",
@@ -293,6 +304,7 @@
293304
]
294305
},
295306
{
307+
"id": "Razor",
296308
"description": "Razor Language Server (Linux / x64)",
297309
"url": "https://download.visualstudio.microsoft.com/download/pr/3b0ae709-c067-48b4-a658-549ca972e437/ad6d340d6d68e760bb1bb7a8073051f3/razorlanguageserver-linux-x64-1.0.0-alpha2-20181112.3.zip",
298310
"installPath": ".razor",
@@ -307,6 +319,7 @@
307319
]
308320
},
309321
{
322+
"id": "Razor",
310323
"description": "Razor Language Server (macOS / x64)",
311324
"url": "https://download.visualstudio.microsoft.com/download/pr/3b0ae709-c067-48b4-a658-549ca972e437/e4808fd370ba60d528944a5a36543cf0/razorlanguageserver-osx-x64-1.0.0-alpha2-20181112.3.zip",
312325
"installPath": ".razor",

src/CSharpExtDownloader.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as util from './common';
76
import { PlatformInformation } from './platform';
8-
import { PackageInstallation, LogPlatformInfo, InstallationSuccess, InstallationFailure } from './omnisharp/loggingEvents';
7+
import { PackageInstallation, LogPlatformInfo, InstallationSuccess } from './omnisharp/loggingEvents';
98
import { EventStream } from './EventStream';
109
import { DownloadAndInstallPackages } from './packageManager/PackageManager';
1110
import { Package } from './packageManager/Package';
@@ -26,30 +25,18 @@ export class CSharpExtDownloader {
2625

2726
public async installRuntimeDependencies(): Promise<boolean> {
2827
this.eventStream.post(new PackageInstallation("C# dependencies"));
29-
let installationStage = 'touchBeginFile';
3028

3129
try {
32-
await util.touchInstallFile(util.InstallFileType.Begin);
3330
// Display platform information and RID
3431
this.eventStream.post(new LogPlatformInfo(this.platformInfo));
3532
let runTimeDependencies = GetRunTimeDependenciesPackages(this.packageJSON);
36-
installationStage = 'downloadAndInstallPackages';
3733
await DownloadAndInstallPackages(runTimeDependencies, this.networkSettingsProvider, this.platformInfo, this.eventStream, this.extensionPath);
38-
installationStage = 'touchLockFile';
39-
await util.touchInstallFile(util.InstallFileType.Lock);
4034
this.eventStream.post(new InstallationSuccess());
4135
return true;
4236
}
4337
catch (error) {
44-
this.eventStream.post(new InstallationFailure(installationStage, error));
4538
return false;
4639
}
47-
finally {
48-
try {
49-
util.deleteInstallFile(util.InstallFileType.Begin);
50-
}
51-
catch (error) { }
52-
}
5340
}
5441
}
5542

src/common.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as cp from 'child_process';
77
import * as fs from 'fs';
88
import * as os from 'os';
99
import * as path from 'path';
10+
import { AbsolutePath } from './packageManager/AbsolutePath';
1011

1112
let extensionPath: string;
1213

@@ -129,18 +130,18 @@ export enum InstallFileType {
129130
Lock
130131
}
131132

132-
function getInstallFilePath(type: InstallFileType): string {
133+
export function getInstallFilePath(folderPath: AbsolutePath, type: InstallFileType): string {
133134
let installFile = 'install.' + InstallFileType[type];
134-
return path.resolve(getExtensionPath(), installFile);
135+
return path.resolve(folderPath.value, installFile);
135136
}
136137

137-
export async function installFileExists(type: InstallFileType): Promise<boolean> {
138-
return fileExists(getInstallFilePath(type));
138+
export async function installFileExists(folderPath: AbsolutePath, type: InstallFileType): Promise<boolean> {
139+
return fileExists(getInstallFilePath(folderPath, type));
139140
}
140141

141-
export async function touchInstallFile(type: InstallFileType): Promise<void> {
142+
export async function touchInstallFile(folderPath: AbsolutePath, type: InstallFileType): Promise<void> {
142143
return new Promise<void>((resolve, reject) => {
143-
fs.writeFile(getInstallFilePath(type), '', err => {
144+
fs.writeFile(getInstallFilePath(folderPath, type), '', err => {
144145
if (err) {
145146
reject(err);
146147
return;
@@ -151,9 +152,9 @@ export async function touchInstallFile(type: InstallFileType): Promise<void> {
151152
});
152153
}
153154

154-
export async function deleteInstallFile(type: InstallFileType): Promise<void> {
155+
export async function deleteInstallFile(folderPath: AbsolutePath, type: InstallFileType): Promise<void> {
155156
return new Promise<void>((resolve, reject) => {
156-
fs.unlink(getInstallFilePath(type), err => {
157+
fs.unlink(getInstallFilePath(folderPath, type), err => {
157158
if (err) {
158159
reject(err);
159160
return;

src/coreclr-debug/activate.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { PlatformInformation } from './../platform';
1111
import { DebuggerPrerequisiteWarning, DebuggerPrerequisiteFailure, DebuggerNotInstalledFailure } from '../omnisharp/loggingEvents';
1212
import { EventStream } from '../EventStream';
1313
import CSharpExtensionExports from '../CSharpExtensionExports';
14+
import { getRuntimeDependencyPackageWithId } from '../tools/GetRuntimeDependencyWithId';
1415

1516
let _debugUtil: CoreClrDebugUtil = null;
1617

@@ -112,7 +113,7 @@ interface AdapterExecutableCommand {
112113
// The default extension manifest calls this command as the adapterExecutableCommand
113114
// If the debugger components have not finished downloading, the proxy displays an error message to the user
114115
// Else it will launch the debug adapter
115-
export async function getAdapterExecutionCommand(platformInfo: PlatformInformation, eventStream: EventStream): Promise<AdapterExecutableCommand> {
116+
export async function getAdapterExecutionCommand(platformInfo: PlatformInformation, eventStream: EventStream, packageJSON: any, extensionPath: string): Promise<AdapterExecutableCommand> {
116117
let util = new CoreClrDebugUtil(common.getExtensionPath());
117118

118119
// Check for .debugger folder. Handle if it does not exist.
@@ -125,7 +126,13 @@ export async function getAdapterExecutionCommand(platformInfo: PlatformInformati
125126
// 4. install.complete is created
126127

127128
// install.Lock does not exist, need to wait for packages to finish downloading.
128-
let installLock: boolean = await common.installFileExists(common.InstallFileType.Lock);
129+
let installLock = false;
130+
let debuggerPackage = getRuntimeDependencyPackageWithId("Debugger", packageJSON, platformInfo, extensionPath);
131+
if (debuggerPackage && debuggerPackage.installPath)
132+
{
133+
installLock = await common.installFileExists(debuggerPackage.installPath, common.InstallFileType.Lock);
134+
}
135+
129136
if (!installLock) {
130137
eventStream.post(new DebuggerNotInstalledFailure());
131138
throw new Error('The C# extension is still downloading packages. Please see progress in the output window below.');

src/features/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import reportIssue from './reportIssue';
2323
import { IMonoResolver } from '../constants/IMonoResolver';
2424
import { getDotnetInfo } from '../utils/getDotnetInfo';
2525

26-
export default function registerCommands(server: OmniSharpServer, platformInfo: PlatformInformation, eventStream: EventStream, optionProvider: OptionProvider, monoResolver: IMonoResolver): CompositeDisposable {
26+
export default function registerCommands(server: OmniSharpServer, platformInfo: PlatformInformation, eventStream: EventStream, optionProvider: OptionProvider, monoResolver: IMonoResolver, packageJSON: any, extensionPath: string): CompositeDisposable {
2727
let disposable = new CompositeDisposable();
2828
disposable.add(vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server)));
2929
disposable.add(vscode.commands.registerCommand('o.pickProjectAndStart', async () => pickProjectAndStart(server, optionProvider)));
@@ -47,8 +47,8 @@ export default function registerCommands(server: OmniSharpServer, platformInfo:
4747
disposable.add(vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args, platformInfo)));
4848

4949
// Register command for adapter executable command.
50-
disposable.add(vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)));
51-
disposable.add(vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)));
50+
disposable.add(vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream, packageJSON, extensionPath)));
51+
disposable.add(vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream, packageJSON, extensionPath)));
5252
disposable.add(vscode.commands.registerCommand('csharp.reportIssue', async () => reportIssue(vscode, eventStream, getDotnetInfo, platformInfo.isValidPlatformForMono(), optionProvider.GetLatestOptions(), monoResolver)));
5353

5454
return new CompositeDisposable(disposable);

src/main.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
159159
}
160160

161161
async function ensureRuntimeDependencies(extension: vscode.Extension<CSharpExtensionExports>, eventStream: EventStream, platformInfo: PlatformInformation, networkSettingsProvider: NetworkSettingsProvider): Promise<boolean> {
162-
return util.installFileExists(util.InstallFileType.Lock)
163-
.then(exists => {
164-
if (!exists) {
165-
const downloader = new CSharpExtDownloader(networkSettingsProvider, eventStream, extension.packageJSON, platformInfo, extension.extensionPath);
166-
return downloader.installRuntimeDependencies();
167-
} else {
168-
return true;
169-
}
170-
});
162+
const downloader = new CSharpExtDownloader(networkSettingsProvider, eventStream, extension.packageJSON, platformInfo, extension.extensionPath);
163+
return downloader.installRuntimeDependencies();
171164
}
172165

src/omnisharp/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an
9898
localDisposables = null;
9999
}));
100100

101-
disposables.add(registerCommands(server, platformInfo, eventStream, optionProvider, omnisharpMonoResolver));
101+
disposables.add(registerCommands(server, platformInfo, eventStream, optionProvider, omnisharpMonoResolver, packageJSON, extensionPath));
102102

103103
if (!context.workspaceState.get<boolean>('assetPromptDisabled')) {
104104
disposables.add(server.onServerStart(() => {

src/packageManager/AbsolutePathPackage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { IPackage } from "./IPackage";
88
import { AbsolutePath } from "./AbsolutePath";
99

1010
export class AbsolutePathPackage implements IPackage{
11-
constructor(public description: string,
11+
constructor(public id: string,
12+
public description: string,
1213
public url: string,
1314
public platforms: string[],
1415
public architectures: string[],
@@ -21,6 +22,7 @@ export class AbsolutePathPackage implements IPackage{
2122

2223
public static getAbsolutePathPackage(pkg: Package, extensionPath: string) {
2324
return new AbsolutePathPackage(
25+
pkg.id,
2426
pkg.description,
2527
pkg.url,
2628
pkg.platforms,

src/packageManager/IPackage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
export interface IPackage {
7+
id: string;
78
description: string;
89
url: string;
910
fallbackUrl?: string;

0 commit comments

Comments
 (0)