From 55673c66d5c96357ae736568efaa529e2829a1bd Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 18 Nov 2026 08:11:20 +0100 Subject: [PATCH 1/7] C#: Udate rules_dotnet and set .NET 11 as target framework in the bazel build. --- MODULE.bazel | 13 +++++++++++-- csharp/scripts/gen-assembly-info.py | 2 +- misc/bazel/csharp.bzl | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index e33e1ff68331..698130356427 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -28,7 +28,7 @@ bazel_dep(name = "nlohmann_json", version = "3.12.0.bcr.2", repo_name = "json") bazel_dep(name = "fmt", version = "12.2.0.bcr.1-codeql.1") bazel_dep(name = "rules_kotlin", version = "2.4.21-codeql.1") bazel_dep(name = "gazelle", version = "0.54.0") -bazel_dep(name = "rules_dotnet", version = "0.22.2-codeql.1") +bazel_dep(name = "rules_dotnet") bazel_dep(name = "googletest", version = "1.18.0.bcr.1") bazel_dep(name = "rules_rust", version = "0.75.0") bazel_dep(name = "rules_swift", version = "4.2.2-codeql.1") @@ -37,6 +37,15 @@ bazel_dep(name = "zstd", version = "1.5.7.bcr.3") bazel_dep(name = "buildifier_prebuilt", version = "10.1.0", dev_dependency = True) +# TODO: +# (1) Investigate whether we still need to patch +# (2) Cleanup our own codeql version of the rules_dotnet. +git_override( + module_name = "rules_dotnet", + commit = "8db43484722080564c2abd04bc09f43f61bf6c65", + remote = "https://github.com/bazel-contrib/rules_dotnet.git", +) + # Pin the compiler to support the Kotlin 1.8 and 1.9 language versions required by older extractors. kotlin = use_extension("@rules_kotlin//src/main/starlark/core/repositories:bzlmod_setup.bzl", "rules_kotlin_extensions") kotlin.kotlinc_version( @@ -222,7 +231,7 @@ http_archive( ) dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet") -dotnet.toolchain(dotnet_version = "10.0.201") +dotnet.toolchain(dotnet_version = "11.0.100") use_repo(dotnet, "dotnet_toolchains") register_toolchains("@dotnet_toolchains//:all") diff --git a/csharp/scripts/gen-assembly-info.py b/csharp/scripts/gen-assembly-info.py index 9937477f70de..7ec6a57a823a 100644 --- a/csharp/scripts/gen-assembly-info.py +++ b/csharp/scripts/gen-assembly-info.py @@ -28,7 +28,7 @@ def options(): [assembly: AssemblyCompany("GitHub")] [assembly: AssemblyCopyright("Copyright © 2024 GitHub")] -[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v11.0", FrameworkDisplayName = ".NET 11.0")] """ output_file.write_text(output_file_contents) diff --git a/misc/bazel/csharp.bzl b/misc/bazel/csharp.bzl index 0cf2e30d0de7..7275b941c7dc 100644 --- a/misc/bazel/csharp.bzl +++ b/misc/bazel/csharp.bzl @@ -2,7 +2,7 @@ load("@rules_dotnet//dotnet:defs.bzl", "csharp_binary", "csharp_library", "cshar load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") load("//misc/bazel:pkg.bzl", "codeql_pkg_files") -TARGET_FRAMEWORK = "net10.0" +TARGET_FRAMEWORK = "net11.0" def _gen_assembly_info(name): assembly_info_gen = name + "-assembly-info" From 0e2a6606b174210c60a4da99aea2b7a620b6b495 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 18 Nov 2026 08:12:09 +0100 Subject: [PATCH 2/7] C#: Update extractor projects to target .NET 11. --- csharp/Directory.Build.props | 2 +- .../Semmle.Extraction.CSharp.DependencyStubGenerator.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/csharp/Directory.Build.props b/csharp/Directory.Build.props index 8046ab10440a..9cab5e1e37aa 100644 --- a/csharp/Directory.Build.props +++ b/csharp/Directory.Build.props @@ -1,7 +1,7 @@ - net10.0 + net11.0 win-x64;linux-x64;osx-x64 enable true diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyStubGenerator/Semmle.Extraction.CSharp.DependencyStubGenerator.csproj b/csharp/extractor/Semmle.Extraction.CSharp.DependencyStubGenerator/Semmle.Extraction.CSharp.DependencyStubGenerator.csproj index 2f05a1f9fe44..31e1839b7cba 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyStubGenerator/Semmle.Extraction.CSharp.DependencyStubGenerator.csproj +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyStubGenerator/Semmle.Extraction.CSharp.DependencyStubGenerator.csproj @@ -2,7 +2,7 @@ Exe - net10.0 + net11.0 Semmle.Extraction.CSharp.DependencyStubGenerator Semmle.Extraction.CSharp.DependencyStubGenerator enable From d041d2789225fe666a77e0c88c12a5cd3ea25f7c Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 18 Nov 2026 08:13:13 +0100 Subject: [PATCH 3/7] C#: Update paket version and run scripts. --- csharp/.config/dotnet-tools.json | 2 +- csharp/.paket/Paket.Restore.targets | 132 +++++++++++++++++----------- csharp/paket.dependencies | 2 +- csharp/paket.lock | 5 +- 4 files changed, 86 insertions(+), 55 deletions(-) diff --git a/csharp/.config/dotnet-tools.json b/csharp/.config/dotnet-tools.json index f4f161bafeeb..4965bfecf746 100644 --- a/csharp/.config/dotnet-tools.json +++ b/csharp/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "paket": { - "version": "10.3.1", + "version": "12.0.0", "commands": [ "paket" ] diff --git a/csharp/.paket/Paket.Restore.targets b/csharp/.paket/Paket.Restore.targets index 8f48b933eb93..18536c51aef2 100644 --- a/csharp/.paket/Paket.Restore.targets +++ b/csharp/.paket/Paket.Restore.targets @@ -16,21 +16,6 @@ $(MSBuildThisFileDirectory)..\ $(PaketRootPath)paket-files\paket.restore.cached $(PaketRootPath)paket.lock - classic - proj - assembly - native - /Library/Frameworks/Mono.framework/Commands/mono - mono - - - $(PaketRootPath)paket.bootstrapper.exe - $(PaketToolsPath)paket.bootstrapper.exe - $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\ - - "$(PaketBootStrapperExePath)" - $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)" - @@ -47,29 +32,32 @@ - + + - - - - $(PaketRootPath)paket - $(PaketToolsPath)paket - - - + + + - - $(PaketRootPath)paket.exe - $(PaketToolsPath)paket.exe + <_PaketFullRootPath>$([System.IO.Path]::GetFullPath('$(PaketRootPath)')) + <_DotnetToolsJsonDir>$([MSBuild]::GetDirectoryNameOfFileAbove('$(_PaketFullRootPath)', '.config/dotnet-tools.json')) + <_DotnetToolsJson Condition=" '$(_DotnetToolsJsonDir)' != '' ">$([System.IO.File]::ReadAllText("$(_DotnetToolsJsonDir)/.config/dotnet-tools.json")) + <_RootDotnetToolsJsonDir>$([MSBuild]::GetDirectoryNameOfFileAbove('$(_PaketFullRootPath)', 'dotnet-tools.json')) + <_DotnetToolsJson Condition=" '$(_RootDotnetToolsJsonDir)' != '' ">$(_DotnetToolsJson)$([System.IO.File]::ReadAllText("$(_RootDotnetToolsJsonDir)/dotnet-tools.json")) + <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$([System.Text.RegularExpressions.Regex]::IsMatch(`$(_DotnetToolsJson)`, `(?i)"paket"\s*:\s*\{`)) + <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false - - + + - <_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json")) - <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"')) - <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false + <_PaketToolPathExeName Condition=" '$(OS)' != 'Windows_NT' ">paket + <_PaketToolPathExeName Condition=" '$(OS)' == 'Windows_NT' ">paket.exe + <_PaketToolPathExe Condition=" $([System.IO.File]::Exists('$(_PaketFullRootPath)$(_PaketToolPathExeName)')) ">$(_PaketFullRootPath)$(_PaketToolPathExeName) + <_PaketToolPathExe Condition=" '$(_PaketToolPathExe)' == '' AND $([System.IO.File]::Exists('$(PaketToolsPath)$(_PaketToolPathExeName)')) ">$(PaketToolsPath)$(_PaketToolPathExeName) + $(_PaketToolPathExe) + @@ -82,21 +70,15 @@ <_PaketCommand>dotnet paket - + - - $(PaketToolsPath)paket - $(PaketBootStrapperExeDir)paket - - - paket + paket <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)")) <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)" - <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)" <_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)" @@ -107,14 +89,13 @@ - - - + + - + @@ -165,8 +146,6 @@ - - @@ -201,6 +180,41 @@ false + + + $(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.lock.hash + + + + $(PaketRestoreLockFileHash) + + + + + + $([System.IO.File]::ReadAllText('$(PaketProjectLockHashCacheFilePath)').Trim()) + true + paket.lock content changed since last per-project restore + + + + true + per-project paket.lock hash cache missing + + false @@ -218,6 +232,11 @@ + + + false @@ -315,6 +334,15 @@ <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/> + + <_PrimaryNuspecFile Include="@(_NuspecFiles)" Exclude="$(AdjustedNuspecOutputPath)\*.symbols.nuspec" Condition="@(_NuspecFiles) != ''" /> + <_PrimaryNuspecFile Include="@(_NuspecFiles)" Condition="@(_PrimaryNuspecFile) == '' And @(_NuspecFiles) != ''" /> @@ -326,12 +354,15 @@ <_ConditionsParameter> - <_ConditionsParameter Condition="@(_DefinedConditionProperties) != ''">--conditions @(_DefinedConditionProperties) + + <_ConditionsParameter Condition="@(_DefinedConditionProperties) != ''">--conditions "@(_DefinedConditionProperties)" - + @@ -383,7 +414,10 @@ PackageLicenseExpression="$(PackageLicenseExpression)" PackageLicenseExpressionVersion="$(PackageLicenseExpressionVersion)" Readme="$(PackageReadmeFile)" - NoDefaultExcludes="$(NoDefaultExcludes)"/> + NoDefaultExcludes="$(NoDefaultExcludes)" + NoWarn="$(NoWarn)" + TreatWarningsAsErrors="$(TreatWarningsAsErrors)" + WarningsAsErrors="$(WarningsAsErrors)"/> = 11.0) System.Reflection.MetadataLoadContext (11.0) - System.Collections.Immutable (>= 11.0) - System.Reflection.Metadata (>= 11.0) System.Runtime.CompilerServices.Unsafe (6.1.2) System.Security.Cryptography.ProtectedData (11.0) System.Text.Encoding.CodePages (11.0) From 3edddd9278b06c9af6cdd9f1d40ff833b7659c60 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 18 Nov 2026 08:13:51 +0100 Subject: [PATCH 4/7] C#: Update the dependency manager to use .NET 11 in case no other unique .NET version is detected. --- .../Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs index 4bd6f6f94870..d5904868bccf 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs @@ -150,7 +150,7 @@ public IList GetNugetFeedsFromFolder(string folderPath) } // The version number should be kept in sync with the version .NET version used for building the application. - public const string LatestDotNetSdkVersion = "10.0.201"; + public const string LatestDotNetSdkVersion = "11.0.100"; public static ReadOnlyDictionary MinimalEnvironment => IDotNetCliInvoker.MinimalEnvironment; From fc3a655b14d1fad3c4728514e6dee08740746e82 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 18 Nov 2026 08:14:04 +0100 Subject: [PATCH 5/7] C#: Update workflows. --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/csharp-qltest.yml | 10 +++++----- csharp/actions/create-extractor-pack/action.yml | 2 +- csharp/scripts/create-extractor-pack.sh | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 99028b8011cb..ac78401fc9d4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: 10.0.201 + dotnet-version: 11.0.100 - name: Checkout repository uses: actions/checkout@v5 diff --git a/.github/workflows/csharp-qltest.yml b/.github/workflows/csharp-qltest.yml index 38ba6b9afacf..137e716fa853 100644 --- a/.github/workflows/csharp-qltest.yml +++ b/.github/workflows/csharp-qltest.yml @@ -51,14 +51,14 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: 10.0.201 + dotnet-version: 11.0.100 - name: Extractor unit tests run: | dotnet tool restore - dotnet test -p:RuntimeFrameworkVersion=10.0.5 extractor/Semmle.Util.Tests - dotnet test -p:RuntimeFrameworkVersion=10.0.5 extractor/Semmle.Extraction.Tests - dotnet test -p:RuntimeFrameworkVersion=10.0.5 autobuilder/Semmle.Autobuild.CSharp.Tests - dotnet test -p:RuntimeFrameworkVersion=10.0.5 autobuilder/Semmle.Autobuild.Cpp.Tests + dotnet test -p:RuntimeFrameworkVersion=11.0.0 extractor/Semmle.Util.Tests + dotnet test -p:RuntimeFrameworkVersion=11.0.0 extractor/Semmle.Extraction.Tests + dotnet test -p:RuntimeFrameworkVersion=11.0.0 autobuilder/Semmle.Autobuild.CSharp.Tests + dotnet test -p:RuntimeFrameworkVersion=11.0.0 autobuilder/Semmle.Autobuild.Cpp.Tests shell: bash stubgentest: runs-on: ubuntu-latest diff --git a/csharp/actions/create-extractor-pack/action.yml b/csharp/actions/create-extractor-pack/action.yml index 05b11dad8c3c..f2e7a0bc1506 100644 --- a/csharp/actions/create-extractor-pack/action.yml +++ b/csharp/actions/create-extractor-pack/action.yml @@ -7,7 +7,7 @@ runs: - name: Setup dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: 10.0.201 + dotnet-version: 11.0.100 - name: Build Extractor shell: bash run: scripts/create-extractor-pack.sh diff --git a/csharp/scripts/create-extractor-pack.sh b/csharp/scripts/create-extractor-pack.sh index 4fbb866b028e..d3e2dbcbc4af 100755 --- a/csharp/scripts/create-extractor-pack.sh +++ b/csharp/scripts/create-extractor-pack.sh @@ -21,7 +21,7 @@ mkdir -p extractor-pack mkdir -p extractor-pack/tools/${platform} function dotnet_publish { - dotnet publish --self-contained --configuration Release --runtime ${dotnet_platform} -p:RuntimeFrameworkVersion=10.0.5 $1 --output extractor-pack/tools/${platform} + dotnet publish --self-contained --configuration Release --runtime ${dotnet_platform} -p:RuntimeFrameworkVersion=11.0.0 $1 --output extractor-pack/tools/${platform} } dotnet tool restore From 8c6847d5e34001a66858248bcf345ef0a278855b Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 18 Nov 2026 13:43:21 +0100 Subject: [PATCH 6/7] C#: Patch rules_dotnet NuGet archive handling Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- MODULE.bazel | 8 +++++--- misc/bazel/patches/BUILD.bazel | 1 + misc/bazel/patches/rules_dotnet_nuget_archive.patch | 13 +++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 misc/bazel/patches/BUILD.bazel create mode 100644 misc/bazel/patches/rules_dotnet_nuget_archive.patch diff --git a/MODULE.bazel b/MODULE.bazel index 698130356427..04cf2407098f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -37,12 +37,14 @@ bazel_dep(name = "zstd", version = "1.5.7.bcr.3") bazel_dep(name = "buildifier_prebuilt", version = "10.1.0", dev_dependency = True) -# TODO: -# (1) Investigate whether we still need to patch -# (2) Cleanup our own codeql version of the rules_dotnet. +# TODO: Cleanup our own codeql version of rules_dotnet. git_override( module_name = "rules_dotnet", commit = "8db43484722080564c2abd04bc09f43f61bf6c65", + patch_strip = 1, + # Keep the patch in a separate package so it can load when the enclosing build + # marks misc/bazel as deleted. + patches = ["//misc/bazel/patches:rules_dotnet_nuget_archive.patch"], remote = "https://github.com/bazel-contrib/rules_dotnet.git", ) diff --git a/misc/bazel/patches/BUILD.bazel b/misc/bazel/patches/BUILD.bazel new file mode 100644 index 000000000000..aa517dba9f09 --- /dev/null +++ b/misc/bazel/patches/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["rules_dotnet_nuget_archive.patch"]) diff --git a/misc/bazel/patches/rules_dotnet_nuget_archive.patch b/misc/bazel/patches/rules_dotnet_nuget_archive.patch new file mode 100644 index 000000000000..7df659192d2d --- /dev/null +++ b/misc/bazel/patches/rules_dotnet_nuget_archive.patch @@ -0,0 +1,13 @@ +--- a/dotnet/private/rules/nuget/nuget_archive.bzl ++++ b/dotnet/private/rules/nuget/nuget_archive.bzl +@@ -219,6 +219,9 @@ def _process_group_with_tfm(groups, group_name, file): + groups["unsupported_tfms"][folder] = True + return +- ++ ++ if len(parts) > 3: ++ return ++ + # Registered before the file is looked at, so that a `_._` placeholder still + # claims the framework: it says the package brings nothing for it, not that + # it does not support it. From 0e1f3b2745eb126c3418e2b6cb27a2815e4c0c88 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 18 Nov 2026 15:23:20 +0100 Subject: [PATCH 7/7] C#: Add extra comment. --- MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/MODULE.bazel b/MODULE.bazel index 04cf2407098f..23ccc2740b02 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -38,6 +38,7 @@ bazel_dep(name = "zstd", version = "1.5.7.bcr.3") bazel_dep(name = "buildifier_prebuilt", version = "10.1.0", dev_dependency = True) # TODO: Cleanup our own codeql version of rules_dotnet. +# Remember that we need to delete the old patch. git_override( module_name = "rules_dotnet", commit = "8db43484722080564c2abd04bc09f43f61bf6c65",