From a72393bc525e219c68a008a499ed0b44c240db06 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Thu, 26 Nov 2026 09:02:38 +0100 Subject: [PATCH 1/2] C#: Disable MSBuild node reuse and the MSBuild server during tracing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- csharp/codeql-extractor.yml | 3 +++ .../all-platforms/dotnet_build/dotnet_build.csproj | 7 +++++++ .../integration-tests/all-platforms/dotnet_build/test.py | 8 ++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/csharp/codeql-extractor.yml b/csharp/codeql-extractor.yml index 8cba8f18e47e..0a43f38800fd 100644 --- a/csharp/codeql-extractor.yml +++ b/csharp/codeql-extractor.yml @@ -7,6 +7,9 @@ column_kind: "utf16" overlay_support_version: 20250626 extra_env_vars: DOTNET_GENERATE_ASPNET_CERTIFICATE: "false" + # The MSBuild server may have been started outside the traced build. + DOTNET_CLI_USE_MSBUILD_SERVER: "false" + MSBUILDDISABLENODEREUSE: "1" build_modes: - autobuild - manual diff --git a/csharp/ql/integration-tests/all-platforms/dotnet_build/dotnet_build.csproj b/csharp/ql/integration-tests/all-platforms/dotnet_build/dotnet_build.csproj index dfb40caafcf9..fa3911a265ec 100644 --- a/csharp/ql/integration-tests/all-platforms/dotnet_build/dotnet_build.csproj +++ b/csharp/ql/integration-tests/all-platforms/dotnet_build/dotnet_build.csproj @@ -7,4 +7,11 @@ enable + + + + + diff --git a/csharp/ql/integration-tests/all-platforms/dotnet_build/test.py b/csharp/ql/integration-tests/all-platforms/dotnet_build/test.py index 75ba09477fa0..43d4885080dc 100644 --- a/csharp/ql/integration-tests/all-platforms/dotnet_build/test.py +++ b/csharp/ql/integration-tests/all-platforms/dotnet_build/test.py @@ -1,4 +1,5 @@ import os +import pytest def check_build_out(msg, s): lines = s.splitlines() @@ -6,8 +7,11 @@ def check_build_out(msg, s): any (("[build-stdout]" in line) and (msg in line) for line in lines) ), f"The C# tracer did not interpret the dotnet path-to-application command correctly." -def test1(codeql, csharp): - codeql.database.create(command="dotnet build") +@pytest.mark.parametrize("command", ["build", "msbuild -restore", "publish", "pack"]) +def test1(codeql, csharp, command): + codeql.database.create( + command=f"dotnet {command} -t:Build,CheckMSBuildServer", + ) # This test checks that we don't inject any flags when running the application using `dotnet` From 2b973cd85055c0683b248cb37ab163c4714de165 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Thu, 26 Nov 2026 11:00:09 +0100 Subject: [PATCH 2/2] C#: Add MSBuild tracing change note Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- csharp/ql/lib/change-notes/2026-11-26-msbuild-tracing.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 csharp/ql/lib/change-notes/2026-11-26-msbuild-tracing.md diff --git a/csharp/ql/lib/change-notes/2026-11-26-msbuild-tracing.md b/csharp/ql/lib/change-notes/2026-11-26-msbuild-tracing.md new file mode 100644 index 000000000000..9f86730773c8 --- /dev/null +++ b/csharp/ql/lib/change-notes/2026-11-26-msbuild-tracing.md @@ -0,0 +1,4 @@ +--- +category: fix +--- +* Disabled MSBuild server and node reuse by default during C# traced builds to improve extraction reliability.