nodejstools: Wrong path to Microsoft.NodejsTools.target with Visual Studio 2017

When creating a Console Node.js project in Visual Studio 2017, and running tests using vstest.console.exe, the path to Microsoft.NodejsTools.target is wrong.:

vstest.console.exe "Project\Project.njsproj" /TestAdapterPath:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\NodeJsTools\NodeJsTools"

Microsoft ® Test Execution Command Line Tool Version 15.0.26228.0 Copyright © Microsoft Corporation. All rights reserved.

Starting test execution, please wait… Error: The imported project “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\Node.js Tools\Microsoft.NodejsTools.targets” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\src\scs-performance-timings\PerformanceTimingsApi\PerformanceTimingsApi.njsproj

The file is actually located here: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Node.js Tools

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Happened to me too, points to wrong folder. VSToolsPath is not correct.

I haven’t been able to reproduce this anymore.

Thanks @paulvanbrenk Groeten uit Nederland

FWIW I currently use a workaround where I have added the following lines to the njsproj file:

<VSToolsPath Condition="Exists('C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild')">C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0</VSToolsPath>
<VSToolsPath Condition="Exists('C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild')">C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0</VSToolsPath>