Skip to content

Commit 2d44deb

Browse files
michaelnebelCopilot
andcommitted
C#: Remove injected MSBuild node-reuse switches
Retain environment safeguards without changing node-reuse command-line options for SDK compatibility. Keep regression coverage for both environment defaults. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 69d78c7 commit 2d44deb

2 files changed

Lines changed: 9 additions & 29 deletions

File tree

‎csharp/ql/integration-tests/all-platforms/dotnet_build/test.py‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,9 @@ def check_build_out(msg, s):
99

1010
@pytest.mark.parametrize("command", ["build", "msbuild -restore", "publish", "pack"])
1111
def test1(codeql, csharp, command):
12-
s = codeql.database.create(
13-
command=f"dotnet {command} -t:Build,CheckMSBuildServer -v:diag -nodeReuse:true",
14-
_capture="stdout",
12+
codeql.database.create(
13+
command=f"dotnet {command} -t:Build,CheckMSBuildServer",
1514
)
16-
assert any(
17-
"[build-stdout]" in line
18-
and "Command line arguments =" in line
19-
and "-nodeReuse:true" in line
20-
and "-nodeReuse:false" in line
21-
and line.rfind("-nodeReuse:false") > line.rfind("-nodeReuse:true")
22-
for line in s.splitlines()
23-
), "The C# tracer did not override the explicit MSBuild node-reuse switch."
2415

2516

2617
# This test checks that we don't inject any flags when running the application using `dotnet`

‎csharp/tools/tracing-config.lua‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function RegisterExtractorPack(id)
4545
-- and `-p:EmitCompilerGeneratedFiles=true` to the command line,
4646
-- otherwise we do nothing.
4747
local match = false
48-
local disableNodeReuse = false
4948
local testMatch = false
5049
local dotnetRunNeedsSeparator = false;
5150
local dotnetRunInjectionIndex = nil;
@@ -78,7 +77,6 @@ function RegisterExtractorPack(id)
7877
if inSubCommandPosition then
7978
if arg == 'build' or arg == 'msbuild' or arg == 'publish' or arg == 'pack' then
8079
match = true
81-
disableNodeReuse = true
8280
break
8381
end
8482
if arg == 'run' then
@@ -118,10 +116,6 @@ function RegisterExtractorPack(id)
118116
end
119117
if match then
120118
local injections = { '-p:UseSharedCompilation=false', '-p:EmitCompilerGeneratedFiles=true' }
121-
if disableNodeReuse then
122-
-- Append so an explicit node-reuse setting cannot override the environment default.
123-
table.insert(injections, '-nodeReuse:false')
124-
end
125119
if dotnetRunNeedsSeparator then
126120
table.insert(injections, '--')
127121
end
@@ -165,25 +159,20 @@ function RegisterExtractorPack(id)
165159
end
166160

167161
function MsBuildMatcher(compilerName, compilerPath, compilerArguments, _languageId)
168-
local isMsBuild = MatchCompilerName('^' .. Exify('msbuild') .. '$', compilerName, compilerPath,
169-
compilerArguments)
170-
if isMsBuild or
162+
if MatchCompilerName('^' .. Exify('msbuild') .. '$', compilerName, compilerPath,
163+
compilerArguments) or
171164
MatchCompilerName('^' .. Exify('xbuild') .. '$', compilerName, compilerPath,
172165
compilerArguments) then
173-
local injections = {
174-
'/p:UseSharedCompilation=false',
175-
'/p:MvcBuildViews=true',
176-
'/p:EmitCompilerGeneratedFiles=true',
177-
}
178-
if isMsBuild then
179-
table.insert(injections, '/nodeReuse:false')
180-
end
181166
return {
182167
order = ORDER_REPLACE,
183168
invocation = BuildExtractorInvocation(id, compilerPath,
184169
compilerPath,
185170
compilerArguments,
186-
nil, injections)
171+
nil, {
172+
'/p:UseSharedCompilation=false',
173+
'/p:MvcBuildViews=true',
174+
'/p:EmitCompilerGeneratedFiles=true',
175+
})
187176

188177
}
189178
end

0 commit comments

Comments
 (0)