File referenced by the protobuf 'CopyPasteTokenInfo' does not exist

Hi,

I’m working on tests for a potential global implementation of Sonar on all our projects.

I have issues that I can solve one by one, but now I need help.

We are in .NET 4.7.2 in GitHub Action. So I’ve been very strongly inspired by the “ConfigureWith” > “GitHub Actions” model.
I added :

  • The checkout with submodules
  • nuget restore
  • microsoft/setup-msbuild@v1.1

Now my project compiles well, sonar installs well, but I have no files analyzed in sonarcloud, only the Qualty Gate passed… I have no exclusion in the Analysis Scope.

The only strange thing is finally the warning
File referenced by the protobuf ‘CopyPasteTokenInfo’ does not exist in the analysis context

I’ve searched the web but I don’t understand how to solve it in GitHub Action. Is it related to MS-Build?

Bellow the log output, the yaml, and 10_Build and scan.txt in attachment.

Many thanks in advance !


  • ALM: GitHub
  • CI : GitHub Action
  • Scanner command: see yaml bellow
  • Languages of the repository: C# .NET 4.7
  • Error: File referenced by the protobuf ‘CopyPasteTokenInfo’ does not exist
  • Steps to reproduce: at every run

[...]
**WARN: File 'D:\a\TEST\TEST\LIB_TBZ\Utils\TBZOtherUtils.cs' referenced by the protobuf 'CopyPasteTokenInfo' does not exist in the analysis context
WARN: File 'D:\a\TEST\TEST\LIB_TBZ\Wrapper\SBuilder.cs' referenced by the protobuf 'CopyPasteTokenInfo' does not exist in the analysis context**
INFO: Importing 1 Roslyn report
INFO: Found 1 MSBuild C# project: 1 MAIN project.
INFO: Sensor C# [csharp] (done) | time=500ms
INFO: Sensor Analysis Warnings import [csharp] (done) | time=0ms
INFO: Sensor C# File Caching Sensor [csharp] (done) | time=0ms
INFO: Sensor Zero Coverage Sensor (done) | time=16ms
INFO: CPD Executor Calculating CPD for 3 files
INFO: CPD Executor CPD calculation finished (done) | time=16ms
INFO: SCM writing changed lines (done) | time=0ms
INFO: Analysis report generated in 2282ms, dir size=232 KB
INFO: Analysis report compressed in 16ms, zip size=50 KB
INFO: Analysis report uploaded in 781ms
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=*
INFO: Sensor cache published successfully
INFO: Analysis total time: 25.521 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 54.967s
INFO: Final Memory: 36M/124M
INFO: ------------------------------------------------------------------------
The SonarScanner CLI has finished
13:54:42.185  Post-processing succeeded.

[10_Build and scan.zip|attachment](upload://na7Ae7rGuThBx8wolfxrIFIfKBg.zip) (21.7 KB)
jobs:
  build_analysis:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v3
        with:
          token: ${{ secrets.SUBMODULE_CLONE }}
          submodules: true
          fetch-depth: 0

      - run: nuget restore "${{ github.workspace }}\${{ github.event.repository.name }}.sln"

      - uses: actions/setup-java@v3
        with:
          java-version: 11
          distribution: "zulu"

      - uses: actions/cache@v3
        with:
          path: ~/.nuget/packages
          key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
          restore-keys: |
            ${{ runner.os }}-nuget-

      - uses: actions/cache@v3
        with:
          path: ~\sonar\cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar

      - id: cache-sonar-scanner
        uses: actions/cache@v3
        with:
          path: .\.sonar\scanner
          key: ${{ runner.os }}-sonar-scanner
          restore-keys: ${{ runner.os }}-sonar-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

      - uses: microsoft/setup-msbuild@v1.1 # Ajoute MSBuild au path

      - name: Build and scan
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        shell: powershell
        run: |
          .\.sonar\scanner\dotnet-sonarscanner.exe begin /k:"tebicomSA_${{ github.event.repository.name }}" /o:"tebicom" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
          MSBuild.exe "${{ github.workspace }}\${{ github.event.repository.name }}.sln" /property:Configuration=Debug
          .\.sonar\scanner\dotnet-sonarscanner.exe end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

Hi,

At a guess, the analyzer thought all your projects were test projects and skipped them. Can you provide debug analysis logs?

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

 
Ann

Thank you very much for your help.

Here are the full logs as requested after adding the debug flags.
logs_54.zip (101.1 KB)

This is the zip archive extracted from GitHub. Do you want me to put some inline ? But there is a lot, I don’t know what to focus on anymore.

Regards,

Hi,

I don’t understand what I’m seeing in these logs. In #10, analysis seems to start, but then the logs go sideways and I don’t see the “EXECUTION SUCCESS” message that you included in your OP.

Are you sure these are the right logs? All the logs? Because somethings’ strange here.

 
Ann

Hi,
Indeed it’s weird, it’s the right log though. One of my “mistakes” in the last test was to add the
/d: “sonar.verbose=true” also to the “dotnet-sonarscanner.exe end. While it should not apparently.

This setting is not valid in the "end" phase in this version of the C# plugin: sonar.verbose

Anyway, here it is corrected and I made a public github repo with a simple little “Hello Sonar”.:

The execution of the action goes relatively well logs_4.zip (339.6 KB) but no analysis sent to SonarCloud :

https://sonarcloud.io/summary/overall?id=tebicomSA_TEST_PUBLIC

I will gladly give you the right plains if you want to try.

06:35:57.1843356Z 06:35:57.184 Pre-processing succeeded.
06:35:57.3031236Z Command line arguments = ""C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" D:\a\TEST_PUBLIC\TEST_PUBLIC\TEST_PUBLIC.sln /property:Configuration=Debug /v:d"
06:35:57.3032035Z Current directory = "D:\a\TEST_PUBLIC\TEST_PUBLIC"
06:36:11.4480023Z Build succeeded.
06:36:11.4490660Z 5 Warning(s)
06:36:11.4490963Z 0 Error(s)
06:36:11.4491434Z Time Elapsed 00:00:14.14
06:36:11.5248962Z SonarScanner for MSBuild 5.12
06:36:11.5250939Z Using the .NET Core version of the Scanner for MSBuild
06:36:11.6131303Z Post-processing started.
06:36:50.9877372Z 06:36:50.967 INFO: 4 files indexed
06:37:00.2808782Z 06:37:00.270 INFO: Importing 1 Roslyn report
06:37:03.8538752Z 06:37:03.836 INFO: Sensor cache published successfully
06:37:03.8539274Z 06:37:03.852 DEBUG: Post-jobs :
06:37:03.8658182Z 06:37:03.852 INFO: Analysis total time: 22.737 s
06:37:03.8659332Z 06:37:03.852 INFO: ------------------------------------------------------------------------
06:37:03.8659736Z 06:37:03.852 INFO: EXECUTION SUCCESS
06:37:03.8947528Z 06:37:03.852 INFO: ------------------------------------------------------------------------
06:37:03.8948557Z 06:37:03.852 INFO: Total time: 51.732s
06:37:03.9655550Z 06:37:03.961 INFO: Final Memory: 36M/124M
06:37:04.5041876Z Process returned exit code 0
06:37:04.5043981Z The SonarScanner CLI has finished
06:37:04.5047419Z 06:37:04.504 Post-processing succeeded.

I just tried to push in master and now it works. I wonder if this whole post makes sense. I don’t understand anymore. We have to push on master once for the analysis of the other (develop) branches to be effective???

Regads,
Julien

Hi Julien,

Had you previously not analyzed your master branch? I don’t believe you should have to analyze it first, but I’ll be honest and say I don’t understand what’s going on here. Also, something strange happened with the critical log, I think:

Selection_995

 
Ann