Search code examples
buildcsproj.net-core-2.0

.Net Core 2 not building my SPA because it can't Exec properly?


I have created an React+Redux using the .Net Core 2.0 template. I didn't change anything yet it's not buildind.

Severity Code Description Project File Line Suppression State Warning MSB3073 The command "node --version" exited with code 1. WebApplication2 C:\Tests\WebApplication2\WebApplication2\WebApplication2.csproj 25

Yet, node is properly installed, when I run "node --version" in a prompt (from any drive/directory) I get v8.4.0 and no error code (the expected behaviour).

I tried using the full path in the .csproj file.

<Exec Command="&quot;C:\Program Files\nodejs\node&quot; --version" ContinueOnError="true">
  <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>

And I'm still getting the same error

Severity Code Description Project File Line Suppression State Warning MSB3073 The command ""C:\Program Files\nodejs\node" --version" exited with code 1. WebApplication2 C:\Tests\WebApplication2\WebApplication2\WebApplication2.csproj 25

I reinstalled NodeJS, with the same results.

Then I even tried a dummy task calling dos echo 0 and it still fails.

Severity Code Description Project File Line Suppression State Warning MSB3073 The command "echo 0" exited with code 1. WebApplication2 C:\Tests\WebApplication2\WebApplication2\WebApplication2.csproj 25

What's going on?

Here's the whole segment which does the check:

<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
  <!-- Ensure Node.js is installed -->
  <Exec Command="&quot;C:\Program Files\nodejs\node&quot; --version" ContinueOnError="true">
    <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
  </Exec>
  <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />

  <!-- In development, the dist files won't exist on the first run or when cloning to
       a different machine, so rebuild them if not already present. -->
  <Message Importance="high" Text="Performing first-run Webpack build..." />
  <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
  <Exec Command="node node_modules/webpack/bin/webpack.js" />
</Target>

Solution

  • This had been related to security issue of some sort.

    Running "dotnet run" from a command prompt run with admin rights "fixed" the issue.