source-building .NET 7 fails when building npmprojects
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
(This is a follow up from https://github.com/dotnet/aspnetcore/issues/42378 which is now locked. Sorry about dropping the ball on that.)
When building ASP.NET Core, turning on source-build mode makes the build fail when it's trying to build nodejs projects
I am currently testing with aspnetcore commit `9ffffa45789328985d43cc70a378fd8570988f27`, but based on the issue linked above, the bug has existed for a while now.
This works:
./eng/build.sh --ci --configuration Release --restore --build --pack
This fails:
./eng/build.sh --ci --configuration Release --restore --build --pack /p:ArcadeBuildFromSource=true
The build failure looks like this:
```
$ yarn run build:lint && yarn run build:esm && yarn run build:cjs && yarn run build:browser && yarn run build:uglify
$ node ../common/node_modules/eslint/bin/eslint ./src --ext .ts --resolve-plugins-relative-to ../common
$ node ../common/node_modules/typescript/bin/tsc --project ./tsconfig.json --module es2015 --outDir ./dist/esm -d $ node ../common/node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs
$ node ../common/node_modules/webpack-cli/bin/cli.js
Duplicate Sources / Packages - No duplicates found. 🚀
asset signalr-protocol-msgpack.js 80.6 KiB [emitted] (name: signalr-protocol-msgpack) 1 related asset asset signalr-protocol-msgpack.min.js 28.6 KiB [emitted] [minimized] (name: signalr-protocol-msgpack.min) 1 related asset
orphan modules 89.3 KiB [orphan] 20 modules
runtime modules 1.31 KiB 6 modules built modules 76.9 KiB [built]
./src/browser-index.ts + 15 modules 76.9 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.75.0 compiled successfully in 2071 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 9.65s.
yarn version v1.22.10
info Current version: 5.0.0-dev
info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
error Invalid version supplied.
/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(108,5): error MSB6006: "yarn" exited with code 1. [/aspnetcore/artifacts/source-build/self/src/src/SignalR/clients/ts/signalr-protocol-msgpack/signalr-protocol-msgpack.npmproj]
##vso[task.logissue type=error;sourcepath=/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets;linenumber=108;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.
/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(108,5): error MSB6006: "yarn" exited with code 1. [/aspnetcore/artifacts/source-build/self/src/src/SignalR/clients/ts/signalr/signalr.npmproj]
##vso[task.logissue type=error;sourcepath=/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets;linenumber=108;columnnumber=5;code=MSB6006;](NETCORE_ENGINEERING_TELEMETRY=Build) "yarn" exited with code 1.
yarn version v1.22.10
info Current version: 8.0.0-dev
error Invalid version supplied.
info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets(108,5): error MSB6006: "yarn" exited with code 1. [/aspnetcore/artifacts/source-build/self/src/src/JSInterop/Microsoft.JSInterop.JS/src/Microsoft.JSInterop.JS.npmproj]
##vso[task.logissue type=error;sourcepath=/aspnetcore/artifacts/source-build/self/src/eng/targets/Npm.Common.targets;linenumber=108;columnnumber=5;code=MSB6006;](NETCORE_ENGINEERING_TELEMETRY=Build) "yarn" exited with code 1.
```
This didn't seem a too big of a problem back when https://github.com/dotnet/aspnetcore/issues/42378 was opened, but with https://github.com/dotnet/aspnetcore/pull/45883/, this issue makes the build break with the VMR.
From what I can tell, `PackageVersion` is set to empty here:
https://github.com/dotnet/aspnetcore/blob/ea683686bfac765690cb6e40f6ba7198cae26e65/eng/targets/Npm.Common.targets#L108
And that makes the `yarn` command fail.
I don't know why `PackageVersion` is empty. I know that arcade handles `${FOO}PackageVersion` specially for `PackageVersions.props`. Could that be setting `PackageVersion` to empty too? Is there some way I can track what's setting `PackageVersion` to empty (or perhaps, not setting to the right version it when it should be set)?
```
$ node --version
v18.12.1
$ yarnpkg --version
1.22.19
$ npm --version
8.19.2
```
cc ~~@chrisrummel~~ @dougbu @mthalman @michaelsimons @wtgodbe
### Expected Behavior
_No response_
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.