This project is read-only.

How do you execute custom targets in NodeJS project files (.njsproj)?

Dec 17, 2014 at 11:03 PM

Is there a way to execute targets in NodeJS project files (njsproj)? I want to execute a Browserify command when building, however, my attempt below does not get fired according to the verbose output from building. Let me know if more detail is needed.

<Target Name="Browserify" BeforeTargets="Build">
    <Exec Command="cd &quot;$(ProjectDir)&quot; &amp;&amp; &quot;$(NodePath)node.exe&quot; &quot;$(NodePath)node_modules\browserify\bin\cmd.js&quot; -t &quot;$(NodePath)node_modules\brfs&quot; &quot;$(ProjectDir)input.js&quot; -o &quot;$(ProjectDir)public\scripts\output.js&quot; --debug" />
Dec 17, 2014 at 11:49 PM
Hmm, it would seem the default target attribute specified on the Project node is not a valid value in the "BeforeTargets" attribute of Target element.

Specifically, the project file has this top-level Project element defined:
<Project DefaultTargets="Build" xmlns="" ToolsVersion="4.0">
I used this "Build" value in the BeforeTargets (see original post), and it is ignored / not recognized. Instead, I'm working around this by using the following:
<Target Name="Browserify" AfterTargets="PrepareForBuild">
Marked as answer by kurifodo on 12/17/2014 at 3:50 PM