Skip to content

Commit 07fc84d

Browse files
committed
C#: Don't inject compiler flags when dotnet is used to execute an application.
1 parent cb128da commit 07fc84d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

csharp/tools/tracing-config.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function RegisterExtractorPack(id)
2323
not isDotnetPath(arg)
2424
end
2525

26+
local function isPathToExecutable(path)
27+
return path:match('%.exe$') or path:match('%.dll')
28+
end
29+
2630
function DotnetMatcherBuild(compilerName, compilerPath, compilerArguments,
2731
_languageId)
2832
if not isDotnet(compilerName) then
@@ -56,8 +60,16 @@ function RegisterExtractorPack(id)
5660
NativeArgumentsToArgv(compilerArguments.nativeArgumentPointer)
5761
end
5862
for i, arg in ipairs(argv) do
63+
-- if dotnet is being used to execute any application except dotnet itself, we should
64+
-- not inject any flags.
65+
if not match and isPathToExecutable(arg) and not isDotnetPath(arg) then
66+
Log(1, 'Execute a .NET application usage detected')
67+
Log(1, 'Dotnet path-to-application detected: %s', arg)
68+
break
69+
end
5970
if isPossibleDotnetSubcommand(arg) then
60-
if (not match) and inSubCommandPosition then
71+
if not match and inSubCommandPosition then
72+
Log(1, 'Execute a .NET SDK command usage detected')
6173
Log(1, 'Dotnet subcommand detected: %s', arg)
6274
end
6375
-- only respond to strings that look like sub-command names if we have not yet
@@ -85,7 +97,7 @@ function RegisterExtractorPack(id)
8597
end
8698
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
8799
-- if an `exe` or `dll` is passed as an argument as the call is forwarded to vstest.
88-
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
100+
if testMatch and isPathToExecutable(arg) then
89101
match = false
90102
break
91103
end

0 commit comments

Comments
 (0)