mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Only inject the shared compilation flag, if argument is not exe or dll.
This commit is contained in:
@@ -23,6 +23,7 @@ function RegisterExtractorPack(id)
|
|||||||
local match = false
|
local match = false
|
||||||
local dotnetRunNeedsSeparator = false;
|
local dotnetRunNeedsSeparator = false;
|
||||||
local dotnetRunInjectionIndex = nil;
|
local dotnetRunInjectionIndex = nil;
|
||||||
|
local libOrExe = false;
|
||||||
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
|
||||||
@@ -37,7 +38,7 @@ function RegisterExtractorPack(id)
|
|||||||
if (not match) then
|
if (not match) then
|
||||||
Log(1, 'Dotnet subcommand detected: %s', arg)
|
Log(1, 'Dotnet subcommand detected: %s', arg)
|
||||||
end
|
end
|
||||||
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' then
|
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' then
|
||||||
match = true
|
match = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -48,6 +49,14 @@ function RegisterExtractorPack(id)
|
|||||||
dotnetRunNeedsSeparator = true
|
dotnetRunNeedsSeparator = true
|
||||||
dotnetRunInjectionIndex = i + 1
|
dotnetRunInjectionIndex = i + 1
|
||||||
end
|
end
|
||||||
|
if arg == 'test' then
|
||||||
|
match = true
|
||||||
|
end
|
||||||
|
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
|
||||||
|
-- if a library or executable is being provided as an argument.
|
||||||
|
if arg:match('%.exe$') or arg:match('%.dll') then
|
||||||
|
libOrExe = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- if we see a separator to `dotnet run`, inject just prior to the existing separator
|
-- if we see a separator to `dotnet run`, inject just prior to the existing separator
|
||||||
if arg == '--' then
|
if arg == '--' then
|
||||||
@@ -62,7 +71,7 @@ function RegisterExtractorPack(id)
|
|||||||
dotnetRunInjectionIndex = i
|
dotnetRunInjectionIndex = i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if match then
|
if match and not libOrExe then
|
||||||
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
|
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
|
||||||
if dotnetRunNeedsSeparator then
|
if dotnetRunNeedsSeparator then
|
||||||
table.insert(injections, '--')
|
table.insert(injections, '--')
|
||||||
|
|||||||
Reference in New Issue
Block a user