Skip to content

Commit d431527

Browse files
authored
Merge pull request #1527 from Microsoft/billti/fixUnitTestDebugging
Explicitly load the VS assemblies on Dev15 to fix unit test debugging
2 parents 78bfe71 + 2611cea commit d431527

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Nodejs/Product/TestAdapter/TestExecutor.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
using System;
1818
using System.Collections.Generic;
1919
using System.Diagnostics;
20+
using System.Globalization;
2021
using System.IO;
2122
using System.Linq;
2223
using System.Net.NetworkInformation;
24+
using System.Reflection;
2325
using System.Runtime.InteropServices;
2426
using System.Text;
2527
using System.Threading;
@@ -30,9 +32,9 @@
3032
using Microsoft.VisualStudioTools;
3133
using Microsoft.VisualStudioTools.Project;
3234
using MSBuild = Microsoft.Build.Evaluation;
33-
using System.Globalization;
3435

35-
namespace Microsoft.NodejsTools.TestAdapter {
36+
namespace Microsoft.NodejsTools.TestAdapter
37+
{
3638
[ExtensionUri(TestExecutor.ExecutorUriString)]
3739
class TestExecutor : ITestExecutor {
3840
public const string ExecutorUriString = "executor://NodejsTestExecutor/v1";
@@ -158,6 +160,26 @@ private void RunTestCase(VisualStudioApp app, IFrameworkHandle frameworkHandle,
158160
return;
159161
}
160162

163+
#if DEV15
164+
// VS 2017 doesn't install some assemblies to the GAC that are needed to work with the
165+
// debugger, and as the tests don't execute in the devenv.exe process, those assemblies
166+
// fail to load - so load them manually from PublicAssemblies.
167+
168+
// Use the executable name, as this is only needed for the out of proc test execution
169+
// that may interact with the debugger (vstest.executionengine.x86.exe).
170+
string currentProc = Process.GetCurrentProcess().MainModule.FileName;
171+
if(Path.GetFileName(currentProc).ToLowerInvariant().Equals("vstest.executionengine.x86.exe"))
172+
{
173+
string baseDir = Path.GetDirectoryName(currentProc);
174+
string publicAssemblies = Path.Combine(baseDir, "..\\..\\..\\PublicAssemblies");
175+
176+
Assembly.LoadFrom(Path.Combine(publicAssemblies, "Microsoft.VisualStudio.OLE.Interop.dll"));
177+
Assembly.LoadFrom(Path.Combine(publicAssemblies, "envdte90.dll"));
178+
Assembly.LoadFrom(Path.Combine(publicAssemblies, "envdte80.dll"));
179+
Assembly.LoadFrom(Path.Combine(publicAssemblies, "envdte.dll"));
180+
}
181+
#endif
182+
161183
NodejsTestInfo testInfo = new NodejsTestInfo(test.FullyQualifiedName);
162184
List<string> args = new List<string>();
163185
int port = 0;

0 commit comments

Comments
 (0)