Skip to content

Commit b9e3cdd

Browse files
authored
Merge pull request #1663 from paulvanbrenk/missingNodeWarning
Warn user when Node is not installed
2 parents 61ace07 + 47f5def commit b9e3cdd

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed

Nodejs/Product/Nodejs/Debugger/NodeDebugProvider.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
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.
22

33
using System;
44
using System.ComponentModel.Composition;
55
using System.IO;
6+
using System.Threading.Tasks;
67
using Microsoft.NodejsTools.Project;
78
using Microsoft.NodejsTools.Telemetry;
89
using Microsoft.VisualStudio.Setup.Configuration;
10+
using Microsoft.VisualStudio.Shell;
911
using Microsoft.VisualStudio.Shell.Interop;
1012
using Microsoft.VisualStudio.Workspace;
1113
using Microsoft.VisualStudio.Workspace.Debug;
1214
using Microsoft.VisualStudio.Workspace.Extensions.VS.Debug;
15+
using Microsoft.VisualStudio.Workspace.VSIntegration.Contracts;
1316
using Newtonsoft.Json.Linq;
1417

1518
namespace Microsoft.NodejsTools.Debugger
@@ -46,10 +49,36 @@ internal class NodeJsDebugLaunchProvider : IVsDebugLaunchTargetProvider
4649
""configuration"": ""#/definitions/nodejsFile""
4750
}";
4851

52+
[Import]
53+
public SVsServiceProvider ServiceProvider { get; set; }
54+
55+
[Import]
56+
public IVsFolderWorkspaceService WorkspaceService { get; set; }
57+
4958
public void SetupDebugTargetInfo(ref VsDebugTargetInfo vsDebugTargetInfo, DebugLaunchActionContext debugLaunchContext)
5059
{
5160
var nodeExe = debugLaunchContext.LaunchConfiguration.GetValue(NodeExeKey, defaultValue: Nodejs.GetPathToNodeExecutableFromEnvironment());
5261

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+
5382
var nodeVersion = Nodejs.GetNodeVersion(nodeExe);
5483
if (nodeVersion >= new Version(8, 0) || NodejsProjectLauncher.CheckDebugProtocolOption())
5584
{

Nodejs/Product/Nodejs/Nodejs.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
115115
<EmbedInteropTypes>True</EmbedInteropTypes>
116116
</Reference>
117+
<Reference Include="Microsoft.VisualStudio.Threading, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
118+
<HintPath>..\..\packages\Microsoft.VisualStudio.Threading.15.3.83\lib\net45\Microsoft.VisualStudio.Threading.dll</HintPath>
119+
<Private>True</Private>
120+
</Reference>
117121
<Reference Include="Microsoft.VisualStudio.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
118122
<Reference Include="Microsoft.VisualStudio.Utilities.Internal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
119123
<HintPath>..\..\packages\Microsoft.VisualStudio.Utilities.Internal.14.0.72-masterF9EB1D39\lib\net45\Microsoft.VisualStudio.Utilities.Internal.dll</HintPath>
@@ -134,6 +138,7 @@
134138
<HintPath>..\..\packages\Microsoft.VisualStudio.Workspaces.15.0.215-pre\lib\net46\Microsoft.VisualStudio.Workspace.Extensions.VS.dll</HintPath>
135139
<Private>False</Private>
136140
</Reference>
141+
<Reference Include="Microsoft.VisualStudio.Workspace.VSIntegration.Contracts, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
137142
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
138143
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
139144
<Private>False</Private>
@@ -195,7 +200,6 @@
195200
<Reference Include="System.Data" />
196201
<Reference Include="System.Design" />
197202
<Reference Include="System.Drawing" />
198-
<Reference Include="System.Runtime.Serialization" />
199203
<Reference Include="System.Web" />
200204
<Reference Include="System.Web.Extensions" />
201205
<Reference Include="System.Windows.Forms" />

Nodejs/Product/Nodejs/Resources.Designer.cs

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

Nodejs/Product/Nodejs/Resources.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,4 +668,8 @@ Error retrieving websocket debug proxy information from web.config.</value>
668668
<data name="NpmExecuteCommand" xml:space="preserve">
669669
<value>Executes npm command. If solution contains multiple projects, specify target project using .npm [ProjectName] &lt;npm arguments&gt;</value>
670670
</data>
671+
<data name="NodejsNotInstalledAnyCode" xml:space="preserve">
672+
<value>Could not find a Node.js runtime on your computer. Please download and install the current Node.js release from 'https://nodejs.org', or specify the location of your Node.exe in the '{0}' file.</value>
673+
<comment>Template contains a filename, like launch.json</comment>
674+
</data>
671675
</root>

Nodejs/Product/Nodejs/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<package id="Microsoft.VisualStudio.RemoteControl" version="14.0.262-masterA5CACE98" targetFramework="net46" />
88
<package id="Microsoft.VisualStudio.Setup.Configuration.Interop" version="1.11.2273" targetFramework="net46" developmentDependency="true" />
99
<package id="Microsoft.VisualStudio.Telemetry" version="15.3.789-masterCC863119" targetFramework="net46" />
10+
<package id="Microsoft.VisualStudio.Threading" version="15.3.83" targetFramework="net46" />
1011
<package id="Microsoft.VisualStudio.Utilities.Internal" version="14.0.72-masterF9EB1D39" targetFramework="net46" />
1112
<package id="Microsoft.VisualStudio.Validation" version="15.3.15" targetFramework="net46" />
1213
<package id="Microsoft.VisualStudio.Workspaces" version="15.0.215-pre" targetFramework="net46" />

0 commit comments

Comments
 (0)