Skip to content

Commit 8eb0b13

Browse files
authored
Fix Test Executor In VS15 Post Preview 4 (#1406)
**Bug** The test executor can currently fail in vs15 post preview 4 because it tries to look up the nodejs.targets file in the global msbuild location. We now only install the targets file to the local, vs specific msbuild folder. **Fix** Similar to with the test discoverer, make sure we use the correct msbuild location
1 parent f4f6253 commit 8eb0b13

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

Nodejs/Product/TestAdapter/TestExecutor.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,28 @@ private void RunTestCase(VisualStudioApp app, IFrameworkHandle frameworkHandle,
226226
}
227227

228228
private NodejsProjectSettings LoadProjectSettings(string projectFile) {
229-
var buildEngine = new MSBuild.ProjectCollection();
229+
var env = new Dictionary<string, string>();
230+
#if DEV15
231+
var root = Environment.GetEnvironmentVariable(NodejsConstants.NodeToolsVsInstallRootEnvironmentVariable);
232+
if (!string.IsNullOrEmpty(root)) {
233+
env["VsInstallRoot"] = root;
234+
env["MSBuildExtensionsPath32"] = Path.Combine(root, "MSBuild");
235+
}
236+
#endif
237+
var buildEngine = new MSBuild.ProjectCollection(env);
230238
var proj = buildEngine.LoadProject(projectFile);
231239

232240
var projectRootDir = Path.GetFullPath(Path.Combine(proj.DirectoryPath, proj.GetPropertyValue(CommonConstants.ProjectHome) ?? "."));
233241

234-
NodejsProjectSettings projSettings = new NodejsProjectSettings();
235-
236-
projSettings.ProjectRootDir = projectRootDir;
242+
return new NodejsProjectSettings() {
243+
ProjectRootDir = projectRootDir,
237244

238-
projSettings.WorkingDir = Path.GetFullPath(Path.Combine(projectRootDir, proj.GetPropertyValue(CommonConstants.WorkingDirectory) ?? "."));
245+
WorkingDir = Path.GetFullPath(Path.Combine(projectRootDir, proj.GetPropertyValue(CommonConstants.WorkingDirectory) ?? ".")),
239246

240-
projSettings.NodeExePath =
241-
Nodejs.GetAbsoluteNodeExePath(
247+
NodeExePath = Nodejs.GetAbsoluteNodeExePath(
242248
projectRootDir,
243-
proj.GetPropertyValue(NodeProjectProperty.NodeExePath));
244-
245-
return projSettings;
249+
proj.GetPropertyValue(NodeProjectProperty.NodeExePath))
250+
};
246251
}
247252

248253
private static void RecordEnd(IFrameworkHandle frameworkHandle, TestCase test, TestResult result, string stdout, string stderr, TestOutcome outcome) {

0 commit comments

Comments
 (0)