Currently, the dotnet-sonarscanner nuget package requires .NET Core 3.1 to run. This version is now end-of-life support at Microsoft, and thus our enterprise is shifting our agent installations off from 3.1 and onto .NET 6.
Is there a planned timeline for upgrading this package to .NET 6+?
Hi Matt, welcome to the community.
While it is true the SonarScanner for .NET still targets 3.1 as a baseline, you can see on the nuget page that it is compatible with .NET 5 through 8, so you can safely use it on your upgraded agents.
Denis
Hi Denis, thanks for responding to the thread.
I have confirmed that I am on the latest version, 6.2.
F:>dotnet sonarscanner
SonarScanner for MSBuild 6.2
Using the .NET Core version of the Scanner for MSBuild
But, when I try to run the nuget package against some .NET 6 code, I get the following error.
E:\deploy\AWS-CHARTBOOK-API\API\AWSChartBook>dotnet sonarscanner end
You must install or update .NET to run this application.
App: C:\Users\Jenkins_Test$.dotnet\tools\dotnet-sonarscanner.exe
Architecture: x64
Framework: ‘Microsoft.NETCore.App’, version ‘3.1.0’ (x64)
.NET location: C:\Program Files\dotnet\
The following frameworks were found:
6.0.30 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.31 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
7.0.19 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
8.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
It seems the runtime dependency still needs .NET Core 3.1, agreed that it can target .NET 5 through 8. I am looking to see when the runtime dependency will be updated.
That is strange, because the Scanner is set to roll forward.
You would not have a global.json file somewhere in your directory or up the hierarchy, perchance?
If you do, would you mind posting the contents?
OK, we have a little bit of a hard time understanding your setup.
You logs show the app to be “C:\Users\Jenkins_Test$.dotnet\tools\dotnet-sonarscanner.exe”, and dotnet-sonarcanner.exe is not in the package we are talking about here.
Would you mind walking us through what you have tried?
Maybe you have remnants of old packages causing problems.
Hey Denis,
No global.json found anywhere on the agent in question.
I think the issue here is versioning, because the only location upon searching for “dotnet-sonarscanner” on the machine in question was in the C:\Users\Jenkins_Test$.dotnet\tools.store\dotnet-sonarscanner, which makes sense because we performed the global install command.
dotnet tool install --global dotnet-sonarscanner --version 6.2.0
But in this folder path, there was an existing version. 5.7.3. Removed, and ran the following command to ensure no conflicts with our AWS CodeArtifact instance.
dotnet tool install --global dotnet-sonarscanner --add-source ‘https://api.nuget.org/v3/index.json’ --ignore-failed-sources
Got past the error, now have to upgrade Java on our box from 11 to 17.
java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
I’m glad we are getting somewhere!
Hi, @mhorger, did you manage to resolve your issues in the end?