From 7c12139c9e0a152a3e2ff6c7666827a5470c4b80 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Fri, 2 Sep 2022 13:51:22 +0200 Subject: [PATCH 1/4] C#: Also inject `/p:UseSharedCompilation=false` into `dotnet publish` --- csharp/tools/tracing-config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/tools/tracing-config.lua b/csharp/tools/tracing-config.lua index 1392b45c36d..d948fb9d1b6 100644 --- a/csharp/tools/tracing-config.lua +++ b/csharp/tools/tracing-config.lua @@ -31,7 +31,7 @@ function RegisterExtractorPack(id) local firstCharacter = string.sub(arg, 1, 1) if not (firstCharacter == '-') and not (firstCharacter == '/') then Log(1, 'Dotnet subcommand detected: %s', arg) - if arg == 'build' or arg == 'msbuild' then match = true end + if arg == 'build' or arg == 'msbuild' or arg == 'publish' then match = true end break end end From 99d9fe14c88bf9682142f932d17016e4a60de6ed Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Fri, 2 Sep 2022 14:17:23 +0200 Subject: [PATCH 2/4] C#: Also inject `dotnet (pack|test|run)` --- csharp/tools/tracing-config.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/csharp/tools/tracing-config.lua b/csharp/tools/tracing-config.lua index d948fb9d1b6..b7db60eff04 100644 --- a/csharp/tools/tracing-config.lua +++ b/csharp/tools/tracing-config.lua @@ -31,7 +31,8 @@ function RegisterExtractorPack(id) local firstCharacter = string.sub(arg, 1, 1) if not (firstCharacter == '-') and not (firstCharacter == '/') then Log(1, 'Dotnet subcommand detected: %s', arg) - if arg == 'build' or arg == 'msbuild' or arg == 'publish' then match = true end + if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' or + arg == 'run' then match = true end break end end From 623ba7926fdb52ace61fbc38fbcf93f4f62cf51c Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Sun, 4 Sep 2022 09:54:21 +0200 Subject: [PATCH 3/4] C#: Fix `/p:UseSharedCompilation=false` tracer injection for `dotnet run` --- csharp/tools/tracing-config.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/csharp/tools/tracing-config.lua b/csharp/tools/tracing-config.lua index b7db60eff04..ea6c1daa717 100644 --- a/csharp/tools/tracing-config.lua +++ b/csharp/tools/tracing-config.lua @@ -19,6 +19,7 @@ function RegisterExtractorPack(id) -- if that's `build`, we append `/p:UseSharedCompilation=false` to the command line, -- otherwise we do nothing. local match = false + local needsSeparator = 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 @@ -31,19 +32,30 @@ function RegisterExtractorPack(id) local firstCharacter = string.sub(arg, 1, 1) if not (firstCharacter == '-') and not (firstCharacter == '/') then Log(1, 'Dotnet subcommand detected: %s', arg) - if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' or - arg == 'run' then match = true end + if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' or arg == 'test' then + match = true + break + 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 + end + end + if arg == '--' then + needsSeparator = false break end end if match then + local injections = { '/p:UseSharedCompilation=false' } + if needsSeparator then + table.insert(injections, '--') + end return { order = ORDER_REPLACE, - invocation = BuildExtractorInvocation(id, compilerPath, - compilerPath, - compilerArguments, nil, { - '/p:UseSharedCompilation=false' - }) + invocation = BuildExtractorInvocation(id, compilerPath, compilerPath, compilerArguments, nil, injections) } end return nil From d8b352c2e62b5d86f98664635801c9a021faecff Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Mon, 5 Sep 2022 10:40:00 +0200 Subject: [PATCH 4/4] C#: Use `-p:` instead of `/p:` with `dotnet` Makes a difference for `dotnet run` where the option will otherwise be considered an argument to the program that is run. --- csharp/tools/tracing-config.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/csharp/tools/tracing-config.lua b/csharp/tools/tracing-config.lua index ea6c1daa717..b34549e73fd 100644 --- a/csharp/tools/tracing-config.lua +++ b/csharp/tools/tracing-config.lua @@ -16,7 +16,7 @@ function RegisterExtractorPack(id) -- For now, parse the command line as follows: -- Everything that starts with `-` (or `/`) will be ignored. -- The first non-option argument is treated as the command. - -- if that's `build`, we append `/p:UseSharedCompilation=false` to the command line, + -- if that's `build`, we append `-p:UseSharedCompilation=false` to the command line, -- otherwise we do nothing. local match = false local needsSeparator = false; @@ -37,7 +37,7 @@ function RegisterExtractorPack(id) break end if arg == 'run' then - -- for `dotnet run`, we need to make sure that `/p:UseSharedCompilation=false` is + -- 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 @@ -49,7 +49,7 @@ function RegisterExtractorPack(id) end end if match then - local injections = { '/p:UseSharedCompilation=false' } + local injections = { '-p:UseSharedCompilation=false' } if needsSeparator then table.insert(injections, '--') end