github / codeql-action

Actions for running CodeQL analysis
MIT License
1.16k stars 321 forks source link

[C Sharp] Error: No source code was seen and extracted to path #865

Open tangirala-aditya opened 2 years ago

tangirala-aditya commented 2 years ago

Hi @criemen, I have tried adding /p:UseSharedCompilation=false to the command line of the dotnet build step. Actually I have CSharp .NET 3.1 tried following documentation in order to publish codeql scan reports in azure devops platform but ended with Error: No code found during the build. Please see: https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning#no-code-found-during-the-build Any suggestions on this!

Originally posted by @tangirala-aditya in https://github.com/github/codeql-action/issues/851#issuecomment-1003437654

criemen commented 2 years ago

Hi, what's the platform you're building on? If it's Windows Server 2022, we're unfortunately not compatible with that yet, and there's nothing you can do about that :(

tangirala-aditya commented 2 years ago

Hi, The platform I am building on is Linux Platform(ubuntu-latest).Would like to know any code changes needed to be included in order to accomplish manual build in (C# .NET 3.1) runtime. So, any suggestions on this?

adityasharad commented 2 years ago

Could you please share your complete Azure DevOps workflow file, and the logs from the failing build?

tangirala-aditya commented 2 years ago

Could you please share your complete Azure DevOps workflow file, and the logs from the failing build?

The following is the yaml file for azure devops pipeline.

trigger: none pool: vmImage: ubuntu-latest stages:

The following are the logs that says the following :

No source code was seen and extracted to /home/vsts/work/1/s/codeql-runner/codeql_databases/csharp. This can occur if the specified build commands failed to compile or process any code.

adityasharad commented 2 years ago

Thanks for sharing the workflow. The problem here is that . codeql-env.sh is not sufficient to export the environment variables for future build steps in Azure DevOps -- you need to use the ADO-specific mechanism for persisting environment variables.

Please follow the example at https://codeql.github.com/docs/codeql-cli/creating-codeql-databases/#example-of-creating-a-codeql-database-using-indirect-build-tracing on using the CodeQL CLI within an Azure DevOps workflow, and let us know if you need further help with it. (That example also uses the CodeQL CLI rather than the CodeQL Runner, since the Runner is deprecated. See these docs on how to migrate.)