Compatibility error because Mac M1 - while running SONAR Cloud for .Net Platform (C#)

Following are the details:

  • ALM used (Gitlab)
  • CI system used (Gitlab)
  • Scanner command used when applicable:
dotnet sonarscanner begin \
  /o:centralpoint \
  /k:centralpoint.io_order-usecase \
  /d:sonar.host.url=https://sonarcloud.io
<insert_your_build_command>
dotnet sonarscanner end
  • Languages of the repository (C#)

Following error is thrown:

Failed to load /opt/homebrew/Cellar/dotnet/8.0.4/libexec/host/fxr/8.0.4/libhostfxr.dylib, error: dlopen(/opt/homebrew/Cellar/dotnet/8.0.4/libexec/host/fxr/8.0.4/libhostfxr.dylib, 0x0001): tried: '/opt/homebrew/Cellar/dotnet/8.0.4/libexec/host/fxr/8.0.4/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/dotnet/8.0.4/libexec/host/fxr/8.0.4/libhostfxr.dylib' (no such file), '/opt/homebrew/Cellar/dotnet/8.0.4/libexec/host/fxr/8.0.4/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
The library libhostfxr.dylib was found, but loading it from /opt/homebrew/Cellar/dotnet/8.0.4/libexec/host/fxr/8.0.4/libhostfxr.dylib failed
  - Installing .NET prerequisites might help resolve this problem.

Hi,

Can you try this on a non-arm64 build agent?

 
Ann

You mean on a laptop with Intel chip?

Hi,

I guess you’re saying you don’t have any non-arm64 build agents for your .NET projects?

 
Ann

Now, I found the build and I am able to run the sonar scanner from local and it is able to push the analysis to Sonar cloud.

The exact same command does not work in Gitlab pipeline. I keep on getting this error Invalid command line parameters. Please specify either 'begin' or 'end', not both.

If I remove the end command, then SONAR analysis is done successful but analysis is not integrated[pushed] to sonar cloud. I do not see the results in there.

Here is the command I am using

      dotnet sonarscanner begin
      /o:<org>
      /k:<org_repo>
      /d:sonar.host.url=https://sonarcloud.io
      /d:sonar.login=${SONAR_TOKEN}
      /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html
      /d:sonar.verbose=true \
      dotnet build \
      dotnet dotcover test --dcReportType=HTML \
      dotnet sonarscanner end /d:sonar.login=${SONAR_TOKEN}

Hi,

Please see my answer to the same post in your other thread:

 
Ann