Skip to content

Commit 9fd9a04

Browse files
authored
Merge pull request #10277 from hvitved/csharp/dotnet-publish-inject
C#: Also inject `/p:UseSharedCompilation=false` into `dotnet publish`
2 parents e8d13d1 + d8b352c commit 9fd9a04

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

csharp/tools/tracing-config.lua

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ function RegisterExtractorPack(id)
1616
-- For now, parse the command line as follows:
1717
-- Everything that starts with `-` (or `/`) will be ignored.
1818
-- The first non-option argument is treated as the command.
19-
-- if that's `build`, we append `/p:UseSharedCompilation=false` to the command line,
19+
-- if that's `build`, we append `-p:UseSharedCompilation=false` to the command line,
2020
-- otherwise we do nothing.
2121
local match = false
22+
local needsSeparator = false;
2223
local argv = compilerArguments.argv
2324
if OperatingSystem == 'windows' then
2425
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -31,18 +32,30 @@ function RegisterExtractorPack(id)
3132
local firstCharacter = string.sub(arg, 1, 1)
3233
if not (firstCharacter == '-') and not (firstCharacter == '/') then
3334
Log(1, 'Dotnet subcommand detected: %s', arg)
34-
if arg == 'build' or arg == 'msbuild' then match = true end
35+
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' then
36+
match = true
37+
break
38+
end
39+
if arg == 'run' then
40+
-- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
41+
-- not passed in as an argument to the program that is run
42+
match = true
43+
needsSeparator = true
44+
end
45+
end
46+
if arg == '--' then
47+
needsSeparator = false
3548
break
3649
end
3750
end
3851
if match then
52+
local injections = { '-p:UseSharedCompilation=false' }
53+
if needsSeparator then
54+
table.insert(injections, '--')
55+
end
3956
return {
4057
order = ORDER_REPLACE,
41-
invocation = BuildExtractorInvocation(id, compilerPath,
42-
compilerPath,
43-
compilerArguments, nil, {
44-
'/p:UseSharedCompilation=false'
45-
})
58+
invocation = BuildExtractorInvocation(id, compilerPath, compilerPath, compilerArguments, nil, injections)
4659
}
4760
end
4861
return nil

0 commit comments

Comments
 (0)