Skip to content

Commit

Permalink
C#: Only inject the shared compilation flag, if argument is not exe o…
Browse files Browse the repository at this point in the history
…r dll.
  • Loading branch information
michaelnebel committed Jun 6, 2023
1 parent 0f010af commit 4dae7ad
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions csharp/tools/tracing-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function RegisterExtractorPack(id)
local match = false
local dotnetRunNeedsSeparator = false;
local dotnetRunInjectionIndex = nil;
local libOrExe = false;
local argv = compilerArguments.argv
if OperatingSystem == 'windows' then
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
Expand All @@ -37,7 +38,7 @@ function RegisterExtractorPack(id)
if (not match) then
Log(1, 'Dotnet subcommand detected: %s', arg)
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
break
end
Expand All @@ -48,6 +49,14 @@ function RegisterExtractorPack(id)
dotnetRunNeedsSeparator = true
dotnetRunInjectionIndex = i + 1
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
-- if we see a separator to `dotnet run`, inject just prior to the existing separator
if arg == '--' then
Expand All @@ -62,7 +71,7 @@ function RegisterExtractorPack(id)
dotnetRunInjectionIndex = i
end
end
if match then
if match and not libOrExe then
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
if dotnetRunNeedsSeparator then
table.insert(injections, '--')
Expand Down

0 comments on commit 4dae7ad

Please sign in to comment.