Template for a good bug report, formatted with Markdown:
- versions used (SonarQube, Scanner, Plugin, and any relevant extension)
- error observed (wrap logs/code around triple quote ``` for proper formatting)
- steps to reproduce
- potential workaround
Hello
I’m pretty new to both SonarCloud and working with C#. But I’m trying to use SonarCloud to analyze repositories on github.
I set up the build file by adding a Secret and then adding a build.yml file with the path .github/workflows/build.yml. This is all according to the Configure with github methods in SonarCloud.io. However I get the error message:
"The SonarScanner for MSBuild integration failed: SonarCloud was unable to collect the required information about your projects."
My build file is defined as:
name: Build
on:
  push:
    branches:
      - master
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build
    runs-on: windows-latest
    steps:
      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 1.11
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Cache SonarCloud packages
        uses: actions/cache@v1
        with:
          path: ~\sonar\cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache SonarCloud scanner
        id: cache-sonar-scanner
        uses: actions/cache@v1
        with:
          path: .\.sonar\scanner
          key: ${{ runner.os }}-sonar-scanner
          restore-keys: ${{ runner.os }}-sonar-scanner
      - name: Install SonarCloud scanner
        if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          New-Item -Path .\.sonar\scanner -ItemType Directory
          dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
      - name: Build and analyze
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        shell: powershell
        run: |
          .\.sonar\scanner\dotnet-sonarscanner begin /k:"path/to/repo" /o:"user" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
          dotnet build
          .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
Does anyone know why this build is failing and the error message occurs?
The whole log is here:
SonarScanner for MSBuild 5.5.3
[13]Using the .NET Core version of the Scanner for MSBuild
[14]Pre-processing started.
[15]Preparing working directories...
[16]09:53:41.185 Updating build integration targets...
[17]09:53:42.008 Fetching analysis configuration settings...
[18]09:53:43.255 Provisioning analyzer assemblies for cs...
[19]09:53:43.256 Installing required Roslyn analyzers...
[20]09:53:44.855 Provisioning analyzer assemblies for vbnet...
[21]09:53:44.855 Installing required Roslyn analyzers...
[22]09:53:44.893 Pre-processing succeeded.
[23]Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
[24]Copyright (C) Microsoft Corporation. All rights reserved.
[25]
[26]Determining projects to restore...
[27]Nothing to do. None of the projects specified contain packages to restore.
[28]C:\Program Files\dotnet\sdk\6.0.200\Microsoft.Common.CurrentVersion.targets(1220,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [Path/to/csproj]
[29]C:\Program Files\dotnet\sdk\6.0.200\Microsoft.Common.CurrentVersion.targets(1220,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [Path/to/csproj]
[30]
[31]Build FAILED.
[32]
[33]C:\Program Files\dotnet\sdk\6.0.200\Microsoft.Common.CurrentVersion.targets(1220,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [Path/to/csproj]
[34]C:\Program Files\dotnet\sdk\6.0.200\Microsoft.Common.CurrentVersion.targets(1220,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [Path/to/csproj]
[35]0 Warning(s)
[36]2 Error(s)
[37]
[38]Time Elapsed 00:00:05.11
[39]SonarScanner for MSBuild 5.5.3
[40]Using the .NET Core version of the Scanner for MSBuild
[41]Post-processing started.
[42]09:53:50.554 The SonarScanner for MSBuild integration failed: SonarCloud was unable to collect the required information about your projects.
[43]09:53:50.554 Generation of the sonar-properties file failed. Unable to complete the analysis.
[44Possible causes:
[45] 1. The project has not been built - the project must be built in between the begin and end steps
[46] 2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
[47] 3. The begin, build and end steps have not all been launched from the same folder
[48] 4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
[49]09:53:50.559 Post-processing failed. Exit code: 1
[50]Error: Process completed with exit code 1.