dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Home Page:https://asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

source-building .NET 7 fails if nodejs is installed on the machine

omajid opened this issue · comments

Describe the Bug

I am trying to build .NET 7 (source-build) from the installer's main branch.

The build fails if nodejs is installed on my machine.

...
      $ node ../common/node_modules/webpack-cli/bin/cli.js

      Duplicate Sources / Packages - No duplicates found. 🚀

      asset signalr-protocol-msgpack.js 79.5 KiB [emitted] (name: signalr-protocol-msgpack) 1 related asset
      asset signalr-protocol-msgpack.min.js 28.1 KiB [emitted] [minimized] (name: signalr-protocol-msgpack.min) 1 related asset
      orphan modules 87.3 KiB [orphan] 20 modules
      runtime modules 1.31 KiB 6 modules
      built modules 75.9 KiB [built]
        ./src/browser-index.ts + 15 modules 75.8 KiB [built] [code generated]
          ModuleConcatenation bailout: Cannot concat with external "signalR": umd externals can't be concatenated
        external "signalR" 42 bytes [built] [code generated]
          ModuleConcatenation bailout: umd externals can't be concatenated
      webpack 5.72.1 compiled successfully in 2625 ms
      $ node ../common/node_modules/terser/bin/terser -m -c --ecma 2019 --module --source-map "url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js
      Done in 11.44s.
      yarn version v1.22.10
      info Current version: 5.0.0-dev
      error Invalid version supplied.
      info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
    dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(105,5): error MSB6006: "yarn" exited with code 1. [dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/src/SignalR/clients/ts/signalr-protocol-msgpack/signalr-protocol-msgpack.npmproj]
    ##vso[task.logissue type=error;sourcepath=dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets;linenumber=105;columnnumber=5;code=MSB6006;](NETCORE_ENGINEERING_TELEMETRY=Build) "yarn" exited with code 1.
      yarn version v1.22.10
      info Current version: 5.0.0-dev
      error Invalid version supplied.
      info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
    dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(105,5): error MSB6006: "yarn" exited with code 1. [dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/src/SignalR/clients/ts/signalr/signalr.npmproj]
    ##vso[task.logissue type=error;sourcepath=dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets;linenumber=105;columnnumber=5;code=MSB6006;](NETCORE_ENGINEERING_TELEMETRY=Build) "yarn" exited with code 1.
      yarn version v1.22.10
      info Current version: 7.0.0-dev
      error Invalid version supplied.
      info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
    dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(105,5): error MSB6006: "yarn" exited with code 1. [dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/src/JSInterop/Microsoft.JSInterop.JS/src/Microsoft.JSInterop.JS.npmproj]                                                                                                                                                                            ##vso[task.logissue type=error;sourcepath=dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets;linenumber=105;columnnumber=5;code=MSB6006;](NETCORE_ENGINEERING_TELEMETRY=Build) "yarn" exited with code 1.

    Build FAILED.

    dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(105,5): error MSB6006: "yarn" exited with code 1. [dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/src/SignalR/clients/ts/signalr-protocol-msgpack/signalr-protocol-msgpack.npmproj]
    dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(105,5): error MSB6006: "yarn" exited with code 1. [dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/src/SignalR/clients/ts/signalr/signalr.npmproj]
    dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(105,5): error MSB6006: "yarn" exited with code 1. [dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/src/JSInterop/Microsoft.JSInterop.JS/src/Microsoft.JSInterop.JS.npmproj]
        0 Warning(s)
        3 Error(s)

It looks like there's some javascript code that deals with versions, and it sees a 7.0.0-dev version string and simply fails.

The build works fine if I uninstall nodejs.

I could not reproduce this error just building aspnetcore repo by itself.

Steps to Reproduce

Install nodejs, build .NET installer (source-build)

Inside a failing build, I can reproduce using:

$ cd /dotnet7.0/dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/src/src/SignalR/clients/ts/signalr
$ /dotnet7.0//dotnet-main-x64-bootstrap/src/aspnetcore/artifacts/source-build/self/package-cache/yarn.msbuild/1.22.10/dist/bin/yarn version --no-git-tag-version --new-version
yarn version v1.22.10
info Current version: 5.0.0-dev
error Invalid version supplied.
info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
$ grep version package.json 
  "version": "5.0.0-dev",
    "prepack": "node ../build/embed-version.js",

Other Information

@dotnet/aspnet-build can you please help triage/route this?

I'm not sure of the best way to handle this nor now widespread a problem it's likely to be. It seems like the main issue relates to our npm versions rather than the installed nodejs version but I'm not sure. @javiercn and @SteveSandersonMS may have useful opinions here.

@omajid what's happening here is Npm.Common.targets updates packages.json files to use versions aligned w/ the current build. This works for me locally but I have node installed locally at v16.15.0 and yarn at v1.22.19. The second one might be the problem for you.

Separately, if you uninstall nodejs, the build automatically disables *.npmproj builds. Npm.Common.targets doesn't hit any problems when it's not used😁

This works

I mean building 7.0.0-dev packages works. Something in yarn (older Yarn) or its supporting packages might be fine w/ e.g. 7.0.0-preview.5.22303.8 packages but not that.

The thing that confuses me is that on the same machine, I can't build aspnetcore via source-build but I can build it standalone. The nodejs version on my machine is the same for both builds.

@SteveSandersonMS @javiercn do you know anything about why this may be happening?

@wtgodbe very likely node is installed on the machine but yarn is not.

npm install --global yarn@1.22.19 should do the trick.

@omajid did Javier's suggestion fix your issue?

Hi @omajid. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.