mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Prepend -p:UseSharedCompilation=false instead of append for dotnet run
This commit is contained in:
@@ -22,6 +22,7 @@ function RegisterExtractorPack(id)
|
|||||||
-- otherwise we do nothing.
|
-- otherwise we do nothing.
|
||||||
local match = false
|
local match = false
|
||||||
local needsSeparator = false;
|
local needsSeparator = false;
|
||||||
|
local injectionIndex = nil;
|
||||||
local argv = compilerArguments.argv
|
local argv = compilerArguments.argv
|
||||||
if OperatingSystem == 'windows' then
|
if OperatingSystem == 'windows' then
|
||||||
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
|
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
|
||||||
@@ -38,13 +39,60 @@ function RegisterExtractorPack(id)
|
|||||||
match = true
|
match = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
if arg == 'run' then
|
||||||
|
-- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
|
||||||
|
-- not passed in as an argument to the program that is run
|
||||||
|
match = true
|
||||||
|
needsSeparator = true
|
||||||
|
injectionIndex = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if arg == '--' then
|
||||||
|
needsSeparator = false
|
||||||
|
injectionIndex = i
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if match then
|
if match then
|
||||||
return {
|
local injections = { '-p:UseSharedCompilation=false' }
|
||||||
order = ORDER_REPLACE,
|
if needsSeparator then
|
||||||
invocation = BuildExtractorInvocation(id, compilerPath, compilerPath, compilerArguments, nil, { '-p:UseSharedCompilation=false' })
|
table.insert(injections, '--')
|
||||||
}
|
end
|
||||||
|
if injectionIndex == nil then
|
||||||
|
-- Simple case; just append at the end
|
||||||
|
return {
|
||||||
|
order = ORDER_REPLACE,
|
||||||
|
invocation = BuildExtractorInvocation(id, compilerPath, compilerPath, compilerArguments, nil,
|
||||||
|
injections)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Complex case; splice injections into the middle of the command line
|
||||||
|
for i, injectionArg in ipairs(injections) do
|
||||||
|
table.insert(argv, injectionIndex + i - 1, injectionArg)
|
||||||
|
end
|
||||||
|
|
||||||
|
if OperatingSystem == 'windows' then
|
||||||
|
return {
|
||||||
|
order = ORDER_REPLACE,
|
||||||
|
invocation = {
|
||||||
|
path = AbsolutifyExtractorPath(id, compilerPath),
|
||||||
|
arguments = {
|
||||||
|
commandLineString = table.concat(argv, " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
order = ORDER_REPLACE,
|
||||||
|
invocation = {
|
||||||
|
path = AbsolutifyExtractorPath(id, compilerPath),
|
||||||
|
arguments = {
|
||||||
|
argv = argv
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user