|
1 | | -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
| 1 | +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
2 | 2 |
|
3 | 3 | using System; |
4 | 4 | using System.ComponentModel.Composition; |
5 | 5 | using System.IO; |
| 6 | +using System.Threading.Tasks; |
6 | 7 | using Microsoft.NodejsTools.Project; |
7 | 8 | using Microsoft.NodejsTools.Telemetry; |
8 | 9 | using Microsoft.VisualStudio.Setup.Configuration; |
| 10 | +using Microsoft.VisualStudio.Shell; |
9 | 11 | using Microsoft.VisualStudio.Shell.Interop; |
10 | 12 | using Microsoft.VisualStudio.Workspace; |
11 | 13 | using Microsoft.VisualStudio.Workspace.Debug; |
12 | 14 | using Microsoft.VisualStudio.Workspace.Extensions.VS.Debug; |
| 15 | +using Microsoft.VisualStudio.Workspace.VSIntegration.Contracts; |
13 | 16 | using Newtonsoft.Json.Linq; |
14 | 17 |
|
15 | 18 | namespace Microsoft.NodejsTools.Debugger |
@@ -46,10 +49,36 @@ internal class NodeJsDebugLaunchProvider : IVsDebugLaunchTargetProvider |
46 | 49 | ""configuration"": ""#/definitions/nodejsFile"" |
47 | 50 | }"; |
48 | 51 |
|
| 52 | + [Import] |
| 53 | + public SVsServiceProvider ServiceProvider { get; set; } |
| 54 | + |
| 55 | + [Import] |
| 56 | + public IVsFolderWorkspaceService WorkspaceService { get; set; } |
| 57 | + |
49 | 58 | public void SetupDebugTargetInfo(ref VsDebugTargetInfo vsDebugTargetInfo, DebugLaunchActionContext debugLaunchContext) |
50 | 59 | { |
51 | 60 | var nodeExe = debugLaunchContext.LaunchConfiguration.GetValue(NodeExeKey, defaultValue: Nodejs.GetPathToNodeExecutableFromEnvironment()); |
52 | 61 |
|
| 62 | + if (string.IsNullOrEmpty(nodeExe)) |
| 63 | + { |
| 64 | + var workspace = this.WorkspaceService.CurrentWorkspace; |
| 65 | + workspace.JTF.Run(async () => |
| 66 | + { |
| 67 | + await workspace.JTF.SwitchToMainThreadAsync(); |
| 68 | + |
| 69 | + VsShellUtilities.ShowMessageBox(this.ServiceProvider, |
| 70 | + string.Format(Resources.NodejsNotInstalledAnyCode, LaunchConfigurationConstants.LaunchJsonFileName), |
| 71 | + Resources.NodejsNotInstalledShort, |
| 72 | + OLEMSGICON.OLEMSGICON_CRITICAL, |
| 73 | + OLEMSGBUTTON.OLEMSGBUTTON_OK, |
| 74 | + OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); |
| 75 | + }); |
| 76 | + |
| 77 | + // This isn't pretty but the only way to not get an additional |
| 78 | + // dialog box, after the one we show. |
| 79 | + throw new TaskCanceledException(); |
| 80 | + } |
| 81 | + |
53 | 82 | var nodeVersion = Nodejs.GetNodeVersion(nodeExe); |
54 | 83 | if (nodeVersion >= new Version(8, 0) || NodejsProjectLauncher.CheckDebugProtocolOption()) |
55 | 84 | { |
|
0 commit comments