File no longer exists - Error in Pull Requests using azure devops

When a PR is raised we are getting several quality gate issues as bellow.

“This file no longer exists in the latest pull request changes. It may have been moved or deleted”
/home/vsts/work/1/s/src/{ourApiProjectNameHere}/wwwroot/spa-page.html

These files are not as part of the PR and its not in source branch either.
This issue started happening suddenly.

  • CI CD used - Azure pipelines
  • SCM - Azure Devops
    “Prepare Analysis Configuration” - Pipeline task is used to configure sonar parameters.

Any help how to avoid these files appearing in the PR?

HI,

Welcome to the community!

Can you identify when it started happening?

Also, can you share your full analysis logs, please?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

Thank you Ann for your reply.

Issue exactly started when we changed our azure pipeline agent from windows-2022 into ubuntu-latest.
I have added 3 log files for each of the pipeline tasks.

1. Prepare Analysis on SonarCloud.txt (2.5 KB)
2. Set Sonar Scanner Parameters.txt (5.3 KB)
3 .Run Code Analysis.txt (516.0 KB)

1 Like

Hi,

Thanks for the logs. Where, exactly, are you seeing this error?

 
Thx,
Ann

We are getting that in the raised PR in azure dev ops.
I have attached a screenshot.

Hi,

Thanks for the context. Do the files

  • exist - at ~those paths - in the project itself?
  • exist - at any path - in the PR?

Specifically, I’m trying to figure out where the error is. Were the files changed in the PR, but SonarCloud analysis somehow mangled the paths? Or did analysis misunderstand what files were changed in the PR?

 
Thx,
Ann

Hi Ann,

/home/vsts/work/1/s/src/-----/----/wwwroot/signin-oidc-silent.html

Only the wwwroot folder exists in the source code and no files in that folder.

And we have not modified any of those files inside wwwroot folder and actually its a empty folder.
But i am not sure during “build” whether any files get added to this folder.

Along with the other modified files, these few files getting displayed in the PR with those errors.

I am attaching the log file from a previous PR build which is before we change the pipelines to ubuntu/linux.

Run Code Analysis - Before moving to ubuntu.txt (998.3 KB)

1 Like

Hi,

Can you check whether signin-oidc-silent.html exists at all in your project?

And if it does, knowing whether it’s a committed file or one generated during the build may also be helpful.

And I’m going to flag this for more expert eyes.

 
Ann

Hi Ann,

signin-oidc-silent.html
spa-page.html
sandbox-download.e083f9d2.js

We are getting file missing error for above 3 files. These are not existing in the project.
Generated only through the build.

Hi,

So the files do exist in the workspace during analysis, right?

And since they’re generated during the build, they would have new timestamps, which is probably related to why they’re picked up as being in the PR.

I see from your log that you’re using the Scanner for .NET, which I believe is supposed to ignore generated files, but I’m not finding that in the docs.

I’m not sure where else to go from here, so I’m going to flag this for more expert eyes.

 
Ann

Yes we have set sonar.exclusions parameter in our prepare analysis pipeline task.
Thank you for spending time on this. I hope if someone can provide a solution for this.

Hi,

To be clear, you’ve set an exclusion to avoid this problem?

 
Thx,
Ann

Hi Ann,

No issue is still there.
Although we have set exclusions for that folder, issue is still there.

1 Like

Hi,

Thanks for clarifying. This is still in queue for the experts.

 
Thx,
Ann

Hello @Sandun_Abeywickrama,

Thank you again for reporting the issue.

To help us identify the issue, can you provide the same logs (Prepare Analysis on SonarCloud and Run Code Analysis) with the verbose mode enabled?

Here is how you can enable it:

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

Thank you

Hello again @Sandun_Abeywickrama,

I think we have come closer to the issue, the fix will be included in the next release of the C# analyzer. The issue is coming from the analyzer not being loaded at the correct step during the analysis.

In the meantime, you can use the sonar.plugins.loadAll=true option. This will ensure the C# analyzer is loaded at the right step to detect the generated files and exclude them from the analysis.

If you are using the Azure DevOps extension, add this option in the SonarCloudPrepare task:

- task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'sonarcloud'
      organization: 'foo'
      scannerMode: 'MSBuild'
      projectKey: 'foo_sonar-scanning-someconsoleapp'
      projectName: 'sonar-scanning-someconsoleapp'
      extraProperties: |
        sonar.plugins.loadAll=true

Otherwise you can specify the option during the begin step when using the CLI:

dotnet sonarscanner begin /k:<project_key> /d:sonar.plugins.loadAll=true

Let me know if this workaround fixes your issue.

Have a nice weekend!

Hi Sebastine

Thanks a lot for spending time on this. I will try this work around and let you know.

Hi!

We are experiencing the same exact issue as described by Sandun.
We tried the fix with:
extraProperties: |
sonar.plugins.loadAll=true

But did not have any luck, the problem is still there.
Is there any other way around the issue?

Hello @mariusam,

Welcome to the community!

Can you share the complete log of both the SonarCloudPrepare and Run Code Analysis tasks in verbose mode?

Here is how you can enable verbose output during the analysis:

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

Thank you,

1 Like