Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeQL failed to compile C# program based on Unity #15807

Open
wwwjwww opened this issue Mar 5, 2024 · 1 comment
Open

CodeQL failed to compile C# program based on Unity #15807

wwwjwww opened this issue Mar 5, 2024 · 1 comment
Assignees
Labels
C# question Further information is requested

Comments

@wwwjwww
Copy link

wwwjwww commented Mar 5, 2024

I want to try codeQL on the Unity program of its C# code in its assets folder. I could execute "msbuild xxx.sln" in my local environment. However, when I try to build codeql database using: codeql database create trial-database --language=csharp --command="msbuild xxx.sln", it reports: CodeQL detected code written in C# but could not process any of it. This can occur if the specified build commands failed to compile or process any code.

  • Confirm that there is some source code for the specified language in the project.
  • For codebases written in Go, JavaScript, TypeScript, and Python, do not specify
    an explicit --command.
  • For other languages, the --command must specify a "clean" build which compiles
    all the source code files without reusing existing build artefacts.

Is it because codeql doesn't support analyzing C# code in a Unity program?

@wwwjwww wwwjwww added the question Further information is requested label Mar 5, 2024
@wwwjwww wwwjwww changed the title General issue CodeQL failed to compile C# program based on Unity CodeQL failed to compile C# program based on Unity Mar 5, 2024
@mbg
Copy link
Member

mbg commented Mar 6, 2024

Hi @wwwjwww 👋🏻

We should be able to analyse the C# code if it gets processed by the C# compiler.

The first thing to check here is the following. Since you are using a custom build command (--command="msbuild xxx.sln") and as the message you received suggests in the last bullet point, your build command must ensure that the code is built from scratch and doesn't inadvertently use previously built artifacts. See the documentation at https://docs.github.com/en/code-security/codeql-cli/getting-started-with-the-codeql-cli/preparing-your-code-for-codeql-analysis#creating-databases-for-compiled-languages for further guidance here.

If that still doesn't work, do you have a link to the repository that you are trying to analyse or any build logs that you can share?

@mbg mbg self-assigned this Mar 6, 2024
@sidshank sidshank added the C# label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants