SonarSource / sonar-scanner-msbuild

SonarScanner for .NET
http://redirect.sonarsource.com/doc/msbuild-sq-runner.html
GNU Lesser General Public License v3.0
365 stars 143 forks source link

Make sure that the scanner works on macOS after .NET 8 release even without workaround #1728

Closed antonioaversa closed 12 months ago

antonioaversa commented 1 year ago

Users have reported that the scanner doesn't work with any .NET 8 Preview version on macOS in this community thread.

It turned out that the issue only happened with preview releases of .NET 8, and it will fix itself with the final release of .NET 8 in November 2023.

A workaround has been provided to the users, to have the scanner working with .NET 8 Preview.

After the .NET 8 final release, we need to make sure that the scanner works on macOS even without this workaround.

rkops-bd commented 12 months ago

Any updates available?

costin-zaharia-sonarsource commented 12 months ago

I've tested the scenario from the community thread (dotnet 7 and 8 installed) and the analysis is working as expected. Please note that I used the release version of .Net 8 (8.0.100).

@rkops-bd I see your comment above. Do you still experience this issue after you update dotnet 8 to the released version and remove the release candidate one?

reinierkops commented 12 months ago

I'm still facing the problem in combination with .net MAUI workloads and ,net8. The build directory is empty on MacOS 13 build host

`Build directory: Bin directory: /Users/runner/work/1/.sonarqube/bin Config directory: /Users/runner/work/1/.sonarqube/conf Output directory: /Users/runner/work/1/.sonarqube/out Config file: /Users/runner/work/1/.sonarqube/conf/SonarQubeAnalysisConfig.xml 14:58:03.428 Generating SonarCloud project properties file to /Users/runner/work/1/.sonarqube/out/sonar-project.properties

[error]14:58:03.43 The SonarScanner for MSBuild integration failed: SonarCloud was unable to collect the required information about your projects.

Possible causes:

  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)

    [debug]Processed: ##vso[task.logissue type=error;]14:58:03.43 The SonarScanner for MSBuild integration failed: SonarCloud was unable to collect the required information about your projects.

    `

costin-zaharia-sonarsource commented 12 months ago

Would it be possible to attach the logs from the begin step in debug mode?

The debug mode is enabled by passing the /d:sonar.verbose=true property when the begin step is invoked.

reinierkops commented 12 months ago

/usr/local/bin/dotnet /Users/runner/work/_tasks/SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255/1.40.2/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll begin /k:[REDACTED] /o:[REDACTED] SonarScanner for MSBuild 5.14 Using the .NET Core version of the Scanner for MSBuild Pre-processing started. Preparing working directories... 14:54:53.403 14:54:53.389 Loading analysis properties from /Users/runner/work/_tasks/SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255/1.40.2/dotnet-sonar-scanner-msbuild/SonarQube.Analysis.xml 14:54:53.403 14:54:53.403 sonar.verbose=true was specified - setting the log verbosity to 'Debug' 14:54:53.406 Updating build integration targets... 14:54:53.42 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/.local/share/Microsoft/MSBuild/4.0/Microsoft.Common.targets/ImportBefore 14:54:53.421 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/.local/share/Microsoft/MSBuild/10.0/Microsoft.Common.targets/ImportBefore 14:54:53.421 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/.local/share/Microsoft/MSBuild/11.0/Microsoft.Common.targets/ImportBefore 14:54:53.422 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/.local/share/Microsoft/MSBuild/12.0/Microsoft.Common.targets/ImportBefore 14:54:53.422 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/.local/share/Microsoft/MSBuild/14.0/Microsoft.Common.targets/ImportBefore 14:54:53.423 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/.local/share/Microsoft/MSBuild/15.0/Microsoft.Common.targets/ImportBefore 14:54:53.423 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/.local/share/Microsoft/MSBuild/Current/Microsoft.Common.targets/ImportBefore 14:54:53.424 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/Microsoft/MSBuild/15.0/Microsoft.Common.targets/ImportBefore 14:54:53.424 Installed SonarQube.Integration.ImportBefore.targets to /Users/runner/Microsoft/MSBuild/Current/Microsoft.Common.targets/ImportBefore 14:54:53.426 Installed SonarQube.Integration.targets to /Users/runner/work/1/.sonarqube/bin/targets 14:54:53.427 Creating config and output folders... 14:54:53.427 Creating directory: /Users/runner/work/1/.sonarqube/conf 14:54:53.427 Creating directory: /Users/runner/work/1/.sonarqube/out 14:54:53.49 Fetching server version... 14:54:53.492 Downloading from https://sonarcloud.io/api/server/version... 14:54:54.193 Response received from https://sonarcloud.io/api/server/version... 14:54:54.196 SonarCloud detected, skipping license check. 14:54:54.201 Fetching analysis configuration settings... 14:54:54.204 Fetching properties for project '[REDACTED]'... 14:54:54.204 Downloading from https://sonarcloud.io/api/settings/values?component=DIG-MAUI-Common... 14:54:54.422 Response received from https://sonarcloud.io/api/settings/values?component=DIG-MAUI-Common... 14:54:54.437 Downloading from https://sonarcloud.io/api/languages/list... 14:54:54.913 Response received from https://sonarcloud.io/api/languages/list... 14:54:54.915 Fetching quality profile for project '[REDACTED]'... 14:54:54.915 Downloading from https://sonarcloud.io/api/qualityprofiles/search?project=DIG-MAUI-Common&organization=[REDACTED]... 14:54:55.177 Response received from https://sonarcloud.io/api/qualityprofiles/search?project=DIG-MAUI-Common&organization=[REDACTED] 14:54:55.182 Downloading from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=[REDACTED]... 14:54:55.708 Response received from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=[REDACTED]... 14:54:55.73 Local analyzer cache: /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources 14:54:55.737 Writing Roslyn generated ruleset to /Users/runner/work/1/.sonarqube/conf/Sonar-cs.ruleset... 14:54:55.756 Writing Roslyn generated ruleset to /Users/runner/work/1/.sonarqube/conf/Sonar-cs-none.ruleset... 14:54:55.759 Provisioning analyzer assemblies for cs... 14:54:55.759 Installing required Roslyn analyzers... 14:54:55.759 Processing plugin: csharp version 9.14.0.81108 14:54:55.839 Cache miss: plugin files were not found in the local cache 14:54:55.84 Fetching resource for plugin: csharp, version 9.14.0.81108. Resource: SonarAnalyzer-9.14.0.81108.zip 14:54:55.841 Downloading SonarAnalyzer-9.14.0.81108.zip to /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/0 14:54:55.842 Downloading file to /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/0/SonarAnalyzer-9.14.0.81108.zip... 14:54:55.842 Downloading from https://sonarcloud.io/static/csharp/SonarAnalyzer-9.14.0.81108.zip... 14:54:56.936 Response received from https://sonarcloud.io/static/csharp/SonarAnalyzer-9.14.0.81108.zip... 14:54:56.938 Extracting files to /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/0... 14:54:56.972 Processing plugin: vbnet version 9.14.0.81108 14:54:56.982 Cache miss: plugin files were not found in the local cache 14:54:56.982 Fetching resource for plugin: vbnet, version 9.14.0.81108. Resource: SonarAnalyzer-9.14.0.81108.zip 14:54:56.982 Downloading SonarAnalyzer-9.14.0.81108.zip to /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/1 14:54:56.982 Downloading file to /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/1/SonarAnalyzer-9.14.0.81108.zip... 14:54:56.983 Downloading from https://sonarcloud.io/static/vbnet/SonarAnalyzer-9.14.0.81108.zip... 14:54:57.922 Response received from https://sonarcloud.io/static/vbnet/SonarAnalyzer-9.14.0.81108.zip... 14:54:57.922 Extracting files to /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/1... 14:54:57.936 Writing Roslyn analyzer additional file to /Users/runner/work/1/.sonarqube/conf/cs/SonarLint.xml... 14:54:57.937 Fetching quality profile for project 'DIG-MAUI-Common'... 14:54:57.937 Downloading from https://sonarcloud.io/api/qualityprofiles/search?project=[REDACTED]&organization=[REDACTED]... 14:54:58.326 Response received from https://sonarcloud.io/api/qualityprofiles/search?project=[REDACTED]&organization=[REDACTED]... 14:54:58.327 Fetching rules for quality profile '[REDACTED]'... 14:54:58.327 Downloading from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=[REDACTED]&p=1... 14:54:58.686 Response received from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=[REDACTED]&p=1... 14:54:58.689 Local analyzer cache: /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources 14:54:58.69 Writing Roslyn generated ruleset to /Users/runner/work/1/.sonarqube/conf/Sonar-vbnet.ruleset... 14:54:58.69 Writing Roslyn generated ruleset to /Users/runner/work/1/.sonarqube/conf/Sonar-vbnet-none.ruleset... 14:54:58.691 Provisioning analyzer assemblies for vbnet... 14:54:58.691 Installing required Roslyn analyzers... 14:54:58.691 Processing plugin: csharp version 9.14.0.81108 14:54:58.692 Cache hit: using plugin files from /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/0 14:54:58.692 Processing plugin: vbnet version 9.14.0.81108 14:54:58.693 Cache hit: using plugin files from /var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/.sonarqube/resources/1 14:54:58.694 Writing Roslyn analyzer additional file to /Users/runner/work/1/.sonarqube/conf/vbnet/SonarLint.xml... 14:54:58.696 Processing analysis cache 14:54:58.699 Incremental PR analysis: Base branch parameter was not provided. 14:54:58.699 Cache data is empty. A full analysis will be performed. 14:54:58.723 Pre-processing succeeded.

[debug]Exit code 0 received from tool '/usr/local/bin/dotnet'

[debug]STDIO streams have closed for tool '/usr/local/bin/dotnet'

costin-zaharia-sonarsource commented 12 months ago

interesting, what is the output of dotnet --info?

reinierkops commented 12 months ago

Generating script. Script contents: dotnet --info ========================== Starting Command Output =========================== /bin/bash /Users/runner/work/_temp/3577e6d4-f23e-436b-b237-e5d3160cfb82.sh .NET SDK: Version: 8.0.100 Commit: 57efcf1350 Workload version: 8.0.100-manifests.6c33ef20

Runtime Environment: OS Name: Mac OS X OS Version: 13.6 OS Platform: Darwin RID: osx-x64 Base Path: /Users/runner/hostedtoolcache/dotnet/sdk/8.0.100/

.NET workloads installed: Workload version: 8.0.100-manifests.6c33ef20 There are no installed workloads to display.

Host: Version: 8.0.0 Architecture: x64 Commit: 5535e31a71

.NET SDKs installed: 8.0.100 [/Users/runner/hostedtoolcache/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.0 [/Users/runner/hostedtoolcache/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.0 [/Users/runner/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: DOTNET_ROOT [/Users/runner/hostedtoolcache/dotnet]

global.json file: Not found

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

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

antonioaversa commented 12 months ago

Hi @reinierkops, @costin-zaharia-sonarsource and I are looking together into your problem, but could not reproduce it. We have a few questions for you that would help us move forward:

  1. would you confirm that neither the first nor the second workaround work for you?
  2. does your project has net8.0 as target framework, or (also) target previous frameworks?
  3. do you reproduce the problem with a simple console application as well (e.g. dotnet new console)?
  4. what are the environment variables set in the context where the scanner executes? In particular, we are looking for variables related to .NET, i.e. the ones from this list.

Thanks a lot!

antonioaversa commented 10 months ago

@reinierkops Hi, did you find a solution to your issue in the end?

pbrissaud commented 10 months ago

Have the same issue. Can provide you logs if you want

costin-zaharia-sonarsource commented 10 months ago

Hi @pbrissaud,

Could you please open a thread on our community forum with the steps you are following, the error that you get, and the logs?

It would be very helpful for us.