Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet test with .NET Framework on Linux/macOS broken w/ .NET SDK 7.0.400 #4657

Closed
bradwilson opened this issue Aug 16, 2023 · 12 comments
Closed

Comments

@bradwilson
Copy link

Description

Running dotnet test --framework net472 with xunit/xunit.analyzers:

  • Using .NET SDK 7.0.400 on Linux or macOS is broken
  • Using .NET SDK 7.0.307 (or 6.0.413) on Linux or macOS is fine
  • Using .NET SDK 7.0.400 on Windows is fine
  • Using .NET 6 instead of .NET Framework 4.7.2 is fine

This appears to be a non-Windows + .NET Framework (Mono) problem, only with the latest .NET SDK 7.

(It may be coincidence, but I noticed that .NET SDK 7.0.400 ships Microsoft (R) Test Execution Command Line Tool Version 17.7.0-preview-23364-03+bc17bb9693cfc4778ded51aa0ab7f1065433f989 which feels suspect given that it's a preview version and not an RTM version. I have verified, though, that this same version is used on Windows as well.)

Example GitHub Actions failure run: https://github.com/xunit/xunit.analyzers/actions/runs/5882040465

Steps to reproduce

From Linux or macOS:

  • Install .NET SDK 7.0.400
  • git clone --recurse-submodules https://github.com/xunit/xunit.analyzers
  • cd xunit.analyzers
  • git switch --detach 513113a87fbbe57246d852e68b2074318a1da748
  • dotnet test src/xunit.analyzers.tests --framework net472

Expected behavior

With 7.0.307:

Test run for /home/bradwilson/dev/1/xunit.analyzers/src/xunit.analyzers.tests/bin/Debug/net472/xunit.analyzers.tests.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 17.6.3 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:  1477, Skipped:     0, Total:  1477, Duration: 1 m 25 s - xunit.analyzers.tests.dll (net472)

Actual behavior

With 7.0.400:

Test run for /home/bradwilson/dev/xunit/analyzers/src/xunit.analyzers.tests/bin/Debug/net472/xunit.analyzers.tests.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 17.7.0-preview-23364-03+bc17bb9693cfc4778ded51aa0ab7f1065433f989 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process for source(s) '/home/bradwilson/dev/xunit/analyzers/src/xunit.analyzers.tests/bin/Debug/net472/xunit.analyzers.tests.dll' exited with error: Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.TestPlatform.ObjectModel.EqtTrace' threw an exception. ---> System.TypeLoadException: Could not load type of field 'Microsoft.VisualStudio.TestPlatform.ObjectModel.PlatformEqtTrace:TraceSourceLevelsMap' (1) due to: Could not resolve type with token 01000019 from typeref (expected class 'System.Diagnostics.TraceLevel' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') assembly:System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Diagnostics.TraceLevel member:(null)
   --- End of inner exception stack trace ---
  at Microsoft.VisualStudio.TestPlatform.TestHost.Program.Main (System.String[] args) [0x00033] in <6059d047aaf14e749a5c8d73c69afc94>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.TestPlatform.ObjectModel.EqtTrace' threw an exception. ---> System.TypeLoadException: Could not load type of field 'Microsoft.VisualStudio.TestPlatform.ObjectModel.PlatformEqtTrace:TraceSourceLevelsMap' (1) due to: Could not resolve type with token 01000019 from typeref (expected class 'System.Diagnostics.TraceLevel' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') assembly:System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Diagnostics.TraceLevel member:(null)
   --- End of inner exception stack trace ---
  at Microsoft.VisualStudio.TestPlatform.TestHost.Program.Main (System.String[] args) [0x00033] in <6059d047aaf14e749a5c8d73c69afc94>:0
. Please check the diagnostic logs for more information.

Test Run Aborted.

Diagnostic logs

https://gist.github.com/bradwilson/be699930236685260ced3eb003c27697

Environment

dotnet --info

.NET SDK:
 Version:   7.0.400
 Commit:    73bf45718d

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.400/

Host:
  Version:      7.0.10
  Architecture: x64
  Commit:       a6dbb800a4

.NET SDKs installed:
  6.0.413 [/usr/share/dotnet/sdk]
  7.0.400 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.21 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.21 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

mono --version

Mono JIT compiler version 6.12.0.200 (tarball Tue Jul 11 21:37:50 UTC 2023)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          yes(610)
        Suspend:       hybrid
        GC:            sgen (concurrent by default)
@nohwnd
Copy link
Member

nohwnd commented Aug 16, 2023

This is probably the same issue as #4549 and #4627, we inserted fix for that into servicing on 7.0.4xx, and it should be in the next service release. (this has links to the insertion pr #4549 (comment))

Could you try the preview build of 7.0.401 from here please? https://github.com/dotnet/installer#table

@nohwnd
Copy link
Member

nohwnd commented Aug 16, 2023

Wait, looking at the binaries in 7.0.401, the have the same version as what you show in the console. Something is wrong.

@nohwnd
Copy link
Member

nohwnd commented Aug 16, 2023

The installer pipeline probably does not produce new builds of 7.0.4xx right now, our insertion is in sdk source code, but the latest insertion from sdk to installer is pretty old. dotnet/installer#16954

So right now you don't have a way to test it I think. 😞

@bradwilson
Copy link
Author

@nohwnd No problem, let me know if/when you have something for me to test.

@bradwilson
Copy link
Author

Also agree that this seem to be the same as #4549.

@nohwnd
Copy link
Member

nohwnd commented Aug 24, 2023

Checked it again today. The installer build is still old.

@Cybrosys
Copy link

Strange, our app build pipeline failed last week on tests, then started working.

But now today I got the same error again:
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.TestPlatform.ObjectModel.EqtTrace' threw an exception. ---> System.TypeLoadException: Could not load type of field 'Microsoft.VisualStudio.TestPlatform.ObjectModel.PlatformEqtTrace:TraceSourceLevelsMap' (1) due to: Could not resolve type with token 01000019 from typeref (expected class 'System.Diagnostics.TraceLevel' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') assembly:System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Diagnostics.TraceLevel member:(null)

@nohwnd
Copy link
Member

nohwnd commented Aug 25, 2023

Are you building on hosted azdo images? Maybe you've hit an agent that already updated, and then hit another one that was not updated yet, and then an updated one again?

@Cybrosys
Copy link

Yeah, Azure DevOps build pipeline and using:

pool:
  vmImage: 'macos-latest'

@Ali-YousefiTelori
Copy link

I got this exception on my source tests:

EasyMicroservices/Serialization#56

@nohwnd
Copy link
Member

nohwnd commented Sep 18, 2023

7.0.401 was released, I checked the nuget and it has 17.7.1 vstest.console, tried running net481 tests on ubuntu (WSL) and it works. So imho fixed, please someone confirm :)

Test run for /mnt/c/Users/jj/Downloads/dotnet-sdk-7.0.401-linux-x64_.tar/dotnet-sdk-7.0.401-linux-x64_/test/bin/Debug/net481/test.dll (.NETFramework,Version=v4.8.1)
Microsoft (R) Test Execution Command Line Tool Version 17.7.1 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 121 ms - test.dll (net481)

@bradwilson
Copy link
Author

👍🏼

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants