Repository navigation
Description
Note:
1.It’s regression issue. It doesn’t repro on dotnet-sdk-7.0.100-preview.5.22225.1-win-arm64.
2. Repro VM: vsengarmsfx041
Builds info:
dotnet-runtime-3.1.26-win-x64
dotnet-sdk-6.0.400-preview.22314.17-win-x64
dotnet-sdk-7.0.100-preview.6.22314.18-win-arm64
dotnet-sdk-7.0.100-preview.6.22314.18-win-x64
dotnet-sdk-7.0.100-preview.6.22314.18-win-x86
Build Link:
https://aka.ms/dotnet/7.0.1xx/daily/dotnet-sdk-win-arm64.exe
https://aka.ms/dotnet/7.0.1xx/daily/dotnet-sdk-win-x64.exe
https://aka.ms/dotnet/7.0.1xx/daily/dotnet-sdk-win-x86.exe
https://aka.ms/dotnet/6.0.4xx/daily/dotnet-sdk-win-x64.exe
https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-3.1.26-windows-x64-installer
Steps:
Execute the following commands by Powershell:
- $env:DOTNET_MULTILEVEL_LOOKUP=0
- ls env:
- dotnet new mstest
- Update file UnitTest1.cs with
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections;
using System.Diagnostics;
using System.Text;
namespace CreateScenarioForVendors
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
StringBuilder builder = new StringBuilder();
builder.AppendLine();
builder.AppendLine();
foreach (DictionaryEntry var in Environment.GetEnvironmentVariables())
{
if(var.Key.ToString().StartsWith("DOTNET_"))
{
builder.AppendLine($"{var.Key.ToString()} {var.Value}");
}
}
builder.AppendLine();
builder.AppendLine();
builder.AppendLine($"ProcessArchitecture {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString()}");
builder.AppendLine($"Location {typeof(object).Assembly.Location}");
builder.AppendLine($"Process name {Process.GetCurrentProcess().Modules[0].FileName}");
throw new Exception(builder.ToString());
}
}
}
Update the project file in in this way
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version=" 17.1.0-preview-20211130-02" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>
</Project>
- dotnet test --framework net7.0 --diag:loga.txt
- &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt
Expected Result:
The command should be run normally as following:

Actual Results:
Fail to run the command – & “C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt

--Log:
PS C:\Users\v-wenjj\Desktop\mstest> dotnet test --framework net7.0 --diag:loga.txt
Determining projects to restore...
All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\7.0.100-preview.6.22314.18\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierIn
ference.targets(219,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support
-policy [C:\Users\v-wenjj\Desktop\mstest\mstest.csproj]
mstest -> C:\Users\v-wenjj\Desktop\mstest\bin\Debug\net7.0\mstest.dll
Test run for C:\Users\v-wenjj\Desktop\mstest\bin\Debug\net7.0\mstest.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220610-03 (arm64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Logging Vstest Diagnostics in file: C:\Users\v-wenjj\Desktop\mstest\loga.txt
A total of 1 test files matched the specified pattern.
Failed TestMethod1 [36 ms]
Error Message:
Test method CreateScenarioForVendors.UnitTest1.TestMethod1 threw exception:
System.Exception:
DOTNET_HOST_PATH C:\Program Files\dotnet\dotnet.exe
DOTNET_MULTILEVEL_LOOKUP 0
ProcessArchitecture Arm64
Location C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.0-preview.6.22312.1\System.Private.CoreLib.dll
Process name C:\Program Files\dotnet\dotnet.exe
Stack Trace:
at CreateScenarioForVendors.UnitTest1.TestMethod1() in C:\Users\v-wenjj\Desktop\mstest\UnitTest1.cs:line 32
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Failed! - Failed: 1, Passed: 0, Skipped: 0, Total: 1, Duration: 58 ms - mstest.dll (net7.0)
PS C:\Users\v-wenjj\Desktop\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt
Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22314.18\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFramewo
rkInference.targets(54,5): "[MSBuild]::GetTargetFrameworkIdentifier(netcoreapp3.1)" canno
t be evaluated. Exception has been thrown by the target of an invocation. [C:\Users\v-wenjj\Desktop\mstest\mstest.cspro
j]
Activity
Evangelink commentedon Jun 15, 2022
Looks like an MSBuild issue based on output:
"[MSBuild]::GetTargetFrameworkIdentifier(netcoreapp3.1)".cc @dsplaisted @marcpopMSFT @rainersigwald Do you know who to root this issue to?
baronfel commentedon Jun 15, 2022
@benvillalobos can you check this since it's ARM related? It looks like the property function is blowing up?
sebastienros commentedon Jun 15, 2022
I have the same error with SDK
7.0.100-preview.6.22306.1but not with SDK7.0.100-preview.6.22302.2benvillalobos commentedon Jun 15, 2022
This is high pri on my radar. Looks like it should be an easy repro
benvillalobos commentedon Jun 16, 2022
Note to self: Maybe we can improve logging here.
benvillalobos commentedon Jun 16, 2022
Notes from investigating
This is a heck of a bug. There's something going on with that x86 dotnet install. I could repro this issue, and discovered a fatal error in the process. Both issues only repro in that x86 dotnet install.
Here's a stack trace I got from the repro:
I think there's a larger issue here WRT x86 dotnet on arm64 machines. I haven't tested this on a non-arm64 machine yet. You can easily repro it (only on x86) with an empty project:
Here's the fatal error:
I captured a log (and removed env vars), it should be attached. It ends abruptly and there's no obvious sign at first glance at what's going on. Will get back to this tomorrow
rainersigwald commentedon Jun 16, 2022
@benvillalobos drive-by question: have you tried with a 6.0.400-preview SDK that has the latest MSBuild bits in it? some of that looks like it might be a runtime problem.
benvillalobos commentedon Jun 16, 2022
After installing6.0.400-preview.22316.6the fatal error issue...disappeared 😐Scratch that. (had to re-include the .net sdk into the project).
The fatal error does not come up in 6.0.400-preview.22316.6 and does come up in 7.0.100-preview.5.22307.18 (global jsoning the project between versions)
6.0.400-preview.22316.6 MSBuild Version: 1c045cf
7.0.100-preview.5.22307.18 MSBuild Version: 1c045cf
6.0.400 successfully repro's this issue, so I can continue the investigation tomorrow. The 7.0.100 looks to have a bigger issue in there.
benvillalobos commentedon Jun 17, 2022
Currently discussing this internally, but it looks like an issue with the runtime.
4 remaining items
danmoseley commentedon Jun 30, 2022
As the stack suggests, it's executing ref-emitted code here. The regex is either NonTransformItemMetadataPattern or ItemMetadataPattern. So main possibilities are - a bug introduced into the compiled regex engine or a bug in the runtime. Either way, that's showing up only when in 32 bit x86 running on Windows Arm64.
@benvillalobos since you have a machine set up that repros this, is it possible to dump (out of the debugger) both the regex pattern, regex options, and the string it's running on? Then paste those into a Hello World app to see whether just running that pattern against that string triggers it. If so -- we've substantially narrowed this down.
v-hozha1 commentedon Jul 11, 2022
This issue also repro on dotnet-sdk-7.0.100-preview.7.22358.13.
Command:
& “C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt
& "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch x64 --diag:logz2.txt
& "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch arm64 --diag:logz2.txt
PS C:\tmp\mstest> & "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch x64 --diag:logz2.txt
Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(55,5): error MSB4184: The expres
sion "[MSBuild]::GetTargetFrameworkVersion(net7.0, 2)" cannot be evaluated. Exception has been thrown by the target of an invocation. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
PS C:\tmp\mstest> & "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch arm64 --diag:logz2.txt
Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
PS C:\tmp\mstest>
mangod9 commentedon Jul 27, 2022
Does this only repro with x86 emulation on arm64? There was a recent fix which was made recently for that.
v-hozha1 commentedon Jul 28, 2022
This issue still repro on today's dotnet-sdk-7.0.100-rc.1.22377.7.
Does this only repro with x86 emulation on arm64?
--Yes. For the x64 emulation on arm64, there's another issue dotnet/msbuild#7721 to track.
mangod9 commentedon Jul 28, 2022
If this is emulation only then its most likely a dupe of #71856.
mangod9 commentedon Aug 3, 2022
A similar issue is closed: #71856, Please validate that this is now fixed.
v-hozha1 commentedon Aug 4, 2022
This issue still repro on today's build dotnet-sdk-7.0.100-rc.1.22403.8. Here is the repro VM: 172.20.30.177
Please refer to the project & dump file from: \mlangfs1\public\v-hozha1\20220804-71098\
PS C:\tmp\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:log1.txt
Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-rc.1.22403.8\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(55,5): error MSB4184: The expression "[MSBuild]::GetTargetFrameworkVersion(net7.0, 2)" cannot be evalua
ted. Exception has been thrown by the target of an invocation. [C:\tmp\mstest\mstest.csproj]
PS C:\tmp\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch x64 --diag:log2.txt
Determining projects to restore...
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at InvokeStub_IntrinsicFunctions.IsOSPlatform(Object, Object, IntPtr*)
PS C:\tmp\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch arm64 --diag:log3.txt
Determining projects to restore...
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at InvokeStub_CheckIfPackageReferenceShouldBeFrameworkReference.get_ShouldRemovePackageReference(Object, Object, IntPtr*)
PS C:\tmp\mstest>
mangod9 commentedon Aug 5, 2022
the fix should be in runtime 7.0.0-rc.1.22403.8 and sdk 7.0.100-rc.1.22404.5
mangod9 commentedon Aug 9, 2022
Closing since this should be fixed.
v-hozha1 commentedon Aug 15, 2022
This issue has been fixed on dotnet-sdk-7.0.100-rc.1.22414.7. Details please refer to below:
