runtime: NRE in System.Text.RegularExpresssions on ARM64
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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 21 (13 by maintainers)
same issue: on WSL2 (ubuntu jammy x86_x64) when I run
docker buildx bake -f docker-compose.yaml
edit: for testing reason I also trieddocker buildx build -t test --platform linux/arm64 .
same result for ARM64 build used image:mcr.microsoft.com/dotnet/sdk:7.0-jammy-arm64v8
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.