Skip to content

Commit 4dae7ad

Browse files
committed
C#: Only inject the shared compilation flag, if argument is not exe or dll.
1 parent 0f010af commit 4dae7ad

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

csharp/tools/tracing-config.lua

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function RegisterExtractorPack(id)
2323
local match = false
2424
local dotnetRunNeedsSeparator = false;
2525
local dotnetRunInjectionIndex = nil;
26+
local libOrExe = false;
2627
local argv = compilerArguments.argv
2728
if OperatingSystem == 'windows' then
2829
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -37,7 +38,7 @@ function RegisterExtractorPack(id)
3738
if (not match) then
3839
Log(1, 'Dotnet subcommand detected: %s', arg)
3940
end
40-
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' then
41+
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' then
4142
match = true
4243
break
4344
end
@@ -48,6 +49,14 @@ function RegisterExtractorPack(id)
4849
dotnetRunNeedsSeparator = true
4950
dotnetRunInjectionIndex = i + 1
5051
end
52+
if arg == 'test' then
53+
match = true
54+
end
55+
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
56+
-- if a library or executable is being provided as an argument.
57+
if arg:match('%.exe$') or arg:match('%.dll') then
58+
libOrExe = true
59+
end
5160
end
5261
-- if we see a separator to `dotnet run`, inject just prior to the existing separator
5362
if arg == '--' then
@@ -62,7 +71,7 @@ function RegisterExtractorPack(id)
6271
dotnetRunInjectionIndex = i
6372
end
6473
end
65-
if match then
74+
if match and not libOrExe then
6675
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
6776
if dotnetRunNeedsSeparator then
6877
table.insert(injections, '--')

0 commit comments

Comments
 (0)