Repository navigation
Closed
Milestone
Description
Steps to reproduce
- Create a new app in VS from template "ASP.NET Core with React.js"
- Name a project and solution as "testspa"
- Select .NET 7
- Create Dockerfile in the solution file directory:
FROM mcr.microsoft.com/dotnet/aspnet:7.0-jammy-arm64v8 AS base
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy-arm64v8 AS build
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs
WORKDIR /src
COPY ["testspa/testspa.csproj", "testspa/"]
RUN dotnet restore "testspa/testspa.csproj"
COPY . .
WORKDIR "/src/testspa"
RUN dotnet build "testspa.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "testspa.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "testspa.dll"]
- Open terminal and go to solution directory
- Build an image:
docker build -t testspa .
Expected result:
A solution should be built and container image should be created
Actual result:
dotnet restore command fails with:
------
> [build 9/12] RUN dotnet restore "testspa/testspa.csproj":
dotnet/msbuild#21 15.85 MSBUILD : error : This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT https://aka.ms/msbuild/unhandled. [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : System.NullReferenceException: Object reference not set to an instance of an object. [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Regex1_Scan(RegexRunner, ReadOnlySpan`1) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at System.Text.RegularExpressions.Regex.ScanInternal(RegexRunnerMode mode, Boolean reuseMatchObject, String input, Int32 beginning, RegexRunner runner, ReadOnlySpan`1 span, Boolean returnNullIfReuseMatchObject) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at System.Text.RegularExpressions.Regex.RunAllMatchesWithCallback[TState](String inputString, ReadOnlySpan`1 inputSpan, Int32 startat, TState& state, MatchCallback`1 callback, RegexRunnerMode mode, Boolean reuseMatchObject) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at System.Text.RegularExpressions.Regex.RunAllMatchesWithCallback[TState](String input, Int32 startat, TState& state, MatchCallback`1 callback, RegexRunnerMode mode, Boolean reuseMatchObject) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at System.Text.RegularExpressions.Regex.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Evaluation.Expander`2.MetadataExpander.ExpandMetadataLeaveEscaped(String expression, IMetadataTable metadata, ExpanderOptions options, IElementLocation elementLocation) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation, LoggingContext loggingContext) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Evaluation.Evaluator`4.EvaluateItemDefinitionElement(ProjectItemDefinitionElement itemDefinitionElement) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Evaluation.Evaluator`4.EvaluateItemDefinitionGroupElement(ProjectItemDefinitionGroupElement itemDefinitionGroupElement) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Evaluation.Evaluator`4.Evaluate() [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, Project project, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Execution.ProjectInstance.Initialize(ProjectRootElement xml, IDictionary`2 globalProperties, String explicitToolsVersion, String explicitSubToolsetVersion, Int32 visualStudioVersionFromSolution, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, Nullable`1 projectLoadSettings, EvaluationContext evaluationContext) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, Nullable`1 projectLoadSettings) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.BackEnd.BuildRequestConfiguration.<>c__DisplayClass60_0.<LoadProjectIntoConfiguration>b__0() [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.BackEnd.BuildRequestConfiguration.InitializeProject(BuildParameters buildParameters, Func`1 loadProjectFromFile) [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.BuildProject() [/src/testspa/testspa.csproj]
dotnet/msbuild#21 15.85 MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport() [/src/testspa/testspa.csproj]
------
Debian
If you try to do the same but with the base image with tag 7.0-bullseye-slim-arm64v8 which is based on Debian, the dotnet restore command also fails with:
------
> [build 9/12] RUN dotnet restore "testspa/testspa.csproj":
dotnet/msbuild#22 17.28 /usr/share/dotnet/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(55,5): error MSB4184: The expression "[MSBuild]::GetTargetFrameworkVersion(net7.0, 2)" cannot be evaluated. Exception has been thrown by the target of an invocation. [/src/testspa/testspa.csproj]
------
.NET 7 on Linux amd64
Everything works well if I use the base images with the tag "7.0" which is targeted amd64. So, it is an ARM issue.
.NET 6 on ARM
If you run the same on .NET6 everything works perfectly with Ubuntu and Debian base images for ARM64v8.
Reacted by Jan Dryk, Dávid Sárkány, Chris Hanna, Erick Yondon and mhoeper
Activity
rainersigwald commentedon Nov 14, 2022
@anmalkov is the host machine you're running on ARM64, or are you using Docker's built in qemu ARM64 emulation?
This one is tracked by NuGet/Home#12227.
rainersigwald commentedon Nov 14, 2022
I don't see anything in the MSBuild-layer calls to
RegularExpression.Replacethat look fishy (or have been touched in a couple years)https://github.com/dotnet/msbuild/blob/d14b74d6f08ab7f2e17706359a38f8c22b569cb5/src/Build/Evaluation/Expander.cs#L901-L957
So I'm going to rename + reroute this to the regex folks in
dotnet/runtime.[-]Unhandled error while building .NET 7 ASP.NET Core with React.js app on ARM64v8[/-][+]NRE in System.Text.RegularExpresssions on ARM64[/+]anmalkov commentedon Nov 17, 2022
I'm building the image on Windows 11, so, on emulation. However, I want to run the container on ARM64
omanikhi commentedon Apr 12, 2023
So 7.x will not be usable on arm64 devices and we need to wait for 8.0?!
stephentoub commentedon Apr 12, 2023
We run a bazillion regex tests on ARM64, and to my knowledge we've never seen such an NRE. It's far from "not usable".
Do you have a standalone repro with just regex that shows the problem you're hitting?
omanikhi commentedon Apr 12, 2023
You're absolutely right about it being far from "not usable", perhaps I was a bit overdramatic in my choice of words.
It actually doesn't happen directly on ARM64 but rather under QEMU emulation of ARM64 (on Ubuntu over x64 in our case) which should be a common production build practice building the project on a non-ARM64 CI server.
I don't have a standalone example that reproduces it but I can certainly try to get one together if it helps.
stephentoub commentedon Apr 12, 2023
Thanks.
@richlander, @AndyAyersMS, do we support / test QEMU emulation of ARM64 on .NET 7?
I'm struggling at the moment to see how this could be an issue specific to regex.
AndyAyersMS commentedon Apr 12, 2023
I don't believe running under QEMU is officially supported, but it would be nice if it worked. My guess is that this indicates a problem in QEMU.
IIRC there is some kind of verbose mode where QEMU can give you more details when it hits something it does not expect. @RobertHenry6bev ran into something like this (though he was emulating x64, not arm64) -- maybe he can suggest how to diagnose these cases.
moo-the-cow commentedon Jun 5, 2023
same issue:
on WSL2 (ubuntu jammy x86_x64)
when I run
docker buildx bake -f docker-compose.yamledit: for testing reason I also tried
docker buildx build -t test --platform linux/arm64 .same resultfor ARM64 build
used image:
mcr.microsoft.com/dotnet/sdk:7.0-jammy-arm64v8mhoeper commentedon Jun 7, 2023
We are facing the same issue, too on Amazon Linux x86_x64
danmoseley commentedon Jun 7, 2023
So neither of you are using QEMU?
mhoeper commentedon Jun 7, 2023
Correct. The NullReferenceException happens as well locally, when I am building with Docker Desktop on Windows on my x86_x64 machine, using --platform linux/arm64 with
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS buildstephentoub commentedon Jun 7, 2023
Targeting arm64 while running on x86/x64 hardware requires emulation. Is this ever happening without emulation?
mhoeper commentedon Jun 7, 2023
Looks like this issue is reproducible as reported from multiple persons and a Nullreference Exception in Regex1_Scan. This is a programming mistake in Msbuild as null check missing and should be easy to fix, right?
stephentoub commentedon Jun 7, 2023
All confirmed cases are using emulated arm64
No.
danmoseley commentedon Jun 7, 2023
@RobertHenry6bev do you have any suggestions folks can try to gather more info here, per suggestion above?
danmoseley commentedon Jun 7, 2023
@jkotas what is the support status of .NET in QEMU -- and if not supported, how well is it known to work?
jkotas commentedon Jun 7, 2023
Not supported. Documented here: https://github.com/dotnet/core/blob/main/release-notes/7.0/supported-os.md#qemu
It is known to be unusable for anything real.
danmoseley commentedon Jun 7, 2023
OK, I'm going to close this as it's a QEMU issue. If anyone is encountering this but not in fact emulating arm64 please open a new issue.