MSBuild integration failed: SonarCloud was unable to collect the required information

Hi - I am new to using SonarCloud. I am a DevOps Engineer working with an application developer to get SonarCloud scans of this codebase in place.

The application is an OLD ASP.Net Web Application. The version of .Net targeted in the .sln file is 4.0.

We are working to integrate using GitHub actions. Here is our build.yml file, which is based off the example provided in the SonarCloud UI.

Note, the additions of the Add msbuild to PATH step, and the use of runs-on: windows-2019 and MSBuild.exe. Those were required to get this far.

name: SonarCloud
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build and analyze
    runs-on: windows-2019
    steps:
      - name: Set up JDK 11
        uses: actions/setup-java@v3
        with:
          java-version: 11
          distribution: 'zulu' # Alternative distribution options are available.
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Cache SonarCloud packages
        uses: actions/cache@v3
        with:
          path: ~\sonar\cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache SonarCloud scanner
        id: cache-sonar-scanner
        uses: actions/cache@v3
        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: Add msbuild to PATH
        uses: microsoft/setup-msbuild@v1.1
      - 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:"REDACTED" /o:"REDACTED" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.verbose=true
          MSBuild.exe REDACTED.sln /t:Rebuild
          .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

Now, we get a build to happen, complete with 572 warnings. However, we get this log.

    572 Warning(s)
    0 Error(s)
Time Elapsed 00:01:36.50
SonarScanner for MSBuild 5.13
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
15:04:50.612  15:04:50.608  Uninstalling target: D:\a\REDACTED\REDACTED\.sonarqube\bin\targets\SonarQube.Integration.targets
15:04:50.612  15:04:50.612  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
15:04:50.613  Loading the SonarCloud analysis config from D:\a\REDACTED\REDACTED\.sonarqube\conf\SonarQubeAnalysisConfig.xml
15:04:50.613  Not running under TeamBuild
15:04:50.613  Analysis base directory: D:\a\REDACTED\REDACTED\.sonarqube
Build directory: 
Bin directory: D:\a\REDACTED\REDACTED\.sonarqube\bin
Config directory: D:\a\REDACTED\REDACTED\.sonarqube\conf
Output directory: D:\a\REDACTED\REDACTED\.sonarqube\out
Config file: D:\a\REDACTED\REDACTED\.sonarqube\conf\SonarQubeAnalysisConfig.xml
15:04:50.616  Generating SonarCloud project properties file to D:\a\REDACTED\REDACTED\.sonarqube\out\sonar-project.properties
15:04:50.619  The SonarScanner for MSBuild integration failed: SonarCloud was unable to collect the required information about your projects.
Possible causes:
15:04:50.619  Generation of the sonar-properties file failed. Unable to complete the analysis.
  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)
15:04:50.623  Writing processing summary to D:\a\REDACTED\REDACTED\.sonarqube\out\ProjectInfo.log
15:04:50.624  Post-processing failed. Exit code: 1
Error: Process completed with exit code 1.

I’ve confirmed a several things related to the likely issues mentioned in the log.

  • The project does build: 572 Warning(s) / 0 Error(s)
  • The version of MSBuild being used is: Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
  • We are using a .sln file.

I am unsure about the warning “The begin, build and end steps have not all been launched from the same folder” warning. Given the yml file above, are there are changes you would suggest?

I’m about (4) hours in to troubleshooting this and I’m unsure where to go from here. Any help anyone can provide wil be greatly appreciated. Thanks in advance.

Hey there.

Can you share logs from the build itself? I can open a private message if you’re more comfortable sharing them there.

Hi Colin - Thanks so much for your help. I’d be happy to send you those over a PM. If you can open that thread, I’ll collect logs and send them over today. Thanks again so much for any help you can provide.

Hey @wdwinslow

I’m coming back to the main thread so I can share my findings with the community.

It looks like you are building a Legacy Web Site Project. This can be determined by how there are no csproj/vbproj, files, and common classes are in an App_Code directory.

Such projects aren’t supported by the Scanner for .NET or SonarCloud: Docs

  • Web Application projects are supported. Legacy Web Site projects are not.

To be able to analyze with SonarCloud, there are some options described in this post:

I hope this helps.

Thanks Colin. I am sorry to have wasted your time with this. During my initial work, I also discovered the file structure indicating this might be a Web Site Project. I then asked the developer who I am working with on this project that question specifically. I even pointed him to the same links you shared. He assured me it was already a Web Application Project. However, initially he did not provide a project file. He later created one. So, I will go back to him and ask for clarification.

1 Like

Hi Colin
Im DevOps Engineer,facing the similar issues but my project is .netframework 4.7.2. Can you please help me. Here’s the error.

13_Run SonarScanner.txt (4.9 KB)

Instead of bumping an old, already-solved thread, I encourage you to start a new thread.