dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.39k stars 10k forks source link

`-no-build-nodejs` without `/p:SkipTestBuild=true` fails build #29944

Closed dougbu closed 3 years ago

dougbu commented 3 years ago

I accidentally hit this in #21487. See https://dev.azure.com/dnceng/public/_build/results?buildId=974989 for example. The following errors occur in that build

/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.1.21073.4/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets(258,5): error MSB3954: Failed to compute hash for file '/datadisks/disk1/workspace/_work/1/s/src/Components/Web.JS/dist/Release/blazor.webassembly.js' because it does not exist or is inaccessible. [/datadisks/disk1/workspace/_work/1/s/src/Components/WebAssembly/testassets/StandaloneApp/StandaloneApp.csproj]
/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.1.21073.4/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets(258,5): error MSB3954: Failed to compute hash for file '/datadisks/disk1/workspace/_work/1/s/src/Components/Web.JS/dist/Release/blazor.webassembly.js' because it does not exist or is inaccessible. [/datadisks/disk1/workspace/_work/1/s/src/Components/WebAssembly/testassets/Wasm.Authentication.Client/Wasm.Authentication.Client.csproj]
/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.1.21073.4/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets(258,5): error MSB3954: Failed to compute hash for file '/datadisks/disk1/workspace/_work/1/s/src/Components/Web.JS/dist/Release/blazor.webassembly.js' because it does not exist or is inaccessible. [/datadisks/disk1/workspace/_work/1/s/src/Components/WebAssembly/testassets/HostedInAspNet.Client/HostedInAspNet.Client.csproj]
/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.1.21073.4/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets(258,5): error MSB3954: Failed to compute hash for file '/datadisks/disk1/workspace/_work/1/s/src/Components/Web.JS/dist/Release/blazor.webassembly.js' because it does not exist or is inaccessible. [/datadisks/disk1/workspace/_work/1/s/src/Components/WebAssembly/testassets/CustomBasePathApp/CustomBasePathApp.csproj]
/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.1.21073.4/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets(258,5): error MSB3954: Failed to compute hash for file '/datadisks/disk1/workspace/_work/1/s/src/Components/Web.JS/dist/Release/blazor.webassembly.js' because it does not exist or is inaccessible. [/datadisks/disk1/workspace/_work/1/s/src/Components/benchmarkapps/Wasm.Performance/TestApp/Wasm.Performance.TestApp.csproj]
/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.1.21073.4/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets(258,5): error MSB3954: Failed to compute hash for file '/datadisks/disk1/workspace/_work/1/s/src/Components/Web.JS/dist/Release/blazor.webassembly.js' because it does not exist or is inaccessible. [/datadisks/disk1/workspace/_work/1/s/src/Components/test/testassets/GlobalizationWasmApp/GlobalizationWasmApp.csproj]
/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.1.21073.4/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets(258,5): error MSB3954: Failed to compute hash for file '/datadisks/disk1/workspace/_work/1/s/src/Components/Web.JS/dist/Release/blazor.webassembly.js' because it does not exist or is inaccessible. [/datadisks/disk1/workspace/_work/1/s/src/Components/test/testassets/BasicTestApp/BasicTestApp.csproj]

The problem is the test assets projects attempt to use the Release version of blazor.webassembly.js which (because of -no-build-nodejs) doesn't exist. Options include

  1. Fail fast (with a much clearer error message) when those projects attempt to build and blazor.webassembly.js doesn't exist
  2. Fall back to the Debug version of the file (which is checked in) when the Release version doesn't exist

Thoughts @dotnet/aspnet-blazor-eng❔

dougbu commented 3 years ago

As a side note

https://github.com/dotnet/aspnetcore/blob/70a880f30cd1537ff3777f51efe18469c8da68db/src/Components/Web.JS/Microsoft.AspNetCore.Components.Web.JS.npmproj#L10-L11

will never match real files on Linux systems because "Release" is always capitalized. That <ItemGroup> may however just be redundant given

https://github.com/dotnet/aspnetcore/blob/70a880f30cd1537ff3777f51efe18469c8da68db/eng/targets/Npm.Common.targets#L29

dougbu commented 3 years ago

Bug causing the current low-level error (which should at least mention building with node when in our repo) is unconditional nature of setting at https://github.com/dotnet/aspnetcore/blob/70a880f30cd1537ff3777f51efe18469c8da68db/src/Components/Directory.Build.targets#L3

That line is fine in most local builds (whether building w/ node or not) because those default to Debug builds. Problem is visible in local builds with -configuration Release and --no-build-nodejs (or -noBuildNodeJS on Windows) after cleaning the repo e.g.

git clean -dfx -e .vs/ -e .vscode/ -e .dotnet/ -e .tools/
.\build.cmd -configuration Release -noBuildNodeJS

On machines lacking node, -noBuildNodeJS or --no-build-nodejs isn't needed to see the problem.

The warning without node installed or with its use disabled mentions "Building NodeJS is disabled so the managed projects will fallback to using the output from previous builds." but that's irrelevant when there is no "previous build" done with node. This should probably be fixed as well.

captainsafia commented 3 years ago

In the Directory.Build.targets above, can we do something like:

<BlazorWebAssemblyJSPath>$(RepoRoot)src\Components\Web.JS\dist\$(Configuration)\blazor.webassembly.js</BlazorWebAssemblyJSPath> 
<BlazorWebAssemblyJSPath Condition="!Exists(BlazorWebAssemblyJSPath)">$(RepoRoot)src\Components\Web.JS\dist\Debug\blazor.webassembly.js</BlazorWebAssemblyJSPath> 

to fallback to the Debug version in the event the Release version is not available?

dougbu commented 3 years ago

fallback to the Debug version

Yeah, that's my second option in the original description. I can handle the fix if that's the direction you want to go. Should the build emit warnings when it does this❔

And, what about the redundant bit mentioned in https://github.com/dotnet/aspnetcore/issues/29944#issuecomment-774340127

dougbu commented 3 years ago

After some offline discussion, we're going with the "fail fast" option because there is no checked-in blazor.webassembly.js file anymore. Specifically, I'll add an <Error> if Microsoft.AspNetCore.Components.WebAssembly.csproj is packed and a <Warning> if any $(UsingMicrosoftNETSdkBlazorWebAssembly) (test) project is built when the file doesn't exist.

I'll also change the Microsoft.AspNetCore.Web.JS.npmproj project to use $(Configuration) instead of release because that's what dependant projects consume.

dougbu commented 3 years ago

@mkArtakMSFT assigned dougbu 1 hour ago

😀

dougbu commented 3 years ago

5923818afcb8