I am captuing stdout and stderror of running a process into a file in windows:
.\run-process > debug-log.txt 2>&1
But the problem is this combines stdout and stderror into a single file which means if I want to play it back using:
type debug-log.txt
Then it will only stdout. I was wondering if there is a way to capture the all outputs and play it back however it was given.
The reason I am asking this is I want to run codeql on my repo and use --command
but it turns out codeql is very slow when it invokes a command (its a known issue). So I thought I can capture the output and trick codeql to think its the output.
codeql database create --language=cpp --source-root=C:\testcodeqldatabase testcodeqldb --command="type release-log.txt"
but I am getting an error from codeql, I think it knows this is just a pipe and not a proper playback of all outputs from a process:
CodeQL did not detect any code written in languages supported by this CodeQL distribution (C/C++, C#, CSV, Go, HTML, Java/Kotlin, JavaScript/TypeScript, Java Properties Files, Python, Ruby, Swift, XML or YAML). Confirm that there is some source code for one of these languages in the project. For more information, review our troubleshooting guide at https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build.
So I thought I can capture the output and trick codeql to think its the output.
This will most likely not work. CodeQL watches the build process to create its database (see documentation):
For compiled languages, extraction works by monitoring the normal build process. Each time a compiler is invoked to process a source file, a copy of that file is made, and all relevant information about the source code is collected. This includes syntactic data about the abstract syntax tree and semantic data about name binding and type information.
So just replaying the build log which you seem to be currently trying will not work; CodeQL needs to watch the actual build process. And this also explains why (at least for compiled languages) the database creation will take longer than a regular build, because CodeQL watches the regular build and additionally creates the CodeQL database meanwhile.
As side note: Maybe for future CodeQL versions, creation of the database for compiled languages will not require performing a build anymore; for Java there is beta support for a new build mode none
, see release notes.