From 24ccce243a58b5a188ee61ed6834462801be369c Mon Sep 17 00:00:00 2001 From: Sarbian Date: Sun, 29 Nov 2026 12:21:19 +0100 Subject: [PATCH 1/2] Convert the projects to SDK style, with PackageReference The four csprojs were legacy (non-SDK) projects with packages.config, which the .NET SDK can not restore. As SDK-style net471 projects, dotnet restore fetches their packages, and Directory.Build.targets adds the net471 reference assemblies package (Microsoft.NETFramework.ReferenceAssemblies.net471), as in MechJeb2, so they build with the .NET SDK on any OS. Kept as before: the sources (the SDK picks up the same files the Compile lists had), LangVersion 8.0, the hand-written AssemblyInfo.cs (GenerateAssemblyInfo false), bin// output paths, DebugType, and the bare KSP references, which Directory.Build.targets resolves through ReferencePath (from .csproj.user locally, from the command line in CI). The post-build copy into KSP (copy_build.sh) is now a target, turned off with -p:CopyBuild=false. CopyLocalFalse is gone: its targets were never imported, so it did nothing. The built ModuleManager.dll has the same assembly references, resources, types and methods as the v4.3.0 release's. --- Directory.Build.targets | 23 ++ ModuleManager/ModuleManager.csproj | 246 +++---------------- ModuleManager/packages.config | 4 - ModuleManagerTests/ModuleManagerTests.csproj | 193 +++------------ ModuleManagerTests/packages.config | 16 -- TestUtils/TestUtils.csproj | 60 ++--- TestUtilsTests/TestUtilsTests.csproj | 112 +++------ TestUtilsTests/packages.config | 12 - 8 files changed, 146 insertions(+), 520 deletions(-) create mode 100644 Directory.Build.targets delete mode 100644 ModuleManager/packages.config delete mode 100644 ModuleManagerTests/packages.config delete mode 100644 TestUtilsTests/packages.config diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 00000000..ba794231 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,23 @@ + + + + + + all + + + + + + $(AssemblySearchPaths);$(ReferencePath) + + + diff --git a/ModuleManager/ModuleManager.csproj b/ModuleManager/ModuleManager.csproj index b45d601b..de42cb69 100644 --- a/ModuleManager/ModuleManager.csproj +++ b/ModuleManager/ModuleManager.csproj @@ -1,218 +1,44 @@ - - + + - Debug - AnyCPU - 10.0.0 - 2.0 - {02C8E3AF-69F9-4102-AB60-DD6DE60662D3} - Library + net471 ModuleManager ModuleManager - v4.7.1 - + {02C8E3AF-69F9-4102-AB60-DD6DE60662D3} + 8.0 + false + false + false - - True + + full - False - bin\Debug\ - DEBUG; - prompt - 4 - False - default - false - + + none - True - bin\Release\ - prompt - 4 - False - false - - - 8.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - False - False - - - False - False - - - - - - False - False - - - False - False - - - False - False - - - False - False - - - False - False - - - False - False - - - False - False - - - False - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sh -c "TARGET_PATH='$(TargetPath)' TARGET_DIR='$(TargetDir)' TARGET_NAME='$(TargetName)' sh '$(ProjectDir)/copy_build.sh'" - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + diff --git a/ModuleManager/packages.config b/ModuleManager/packages.config deleted file mode 100644 index a9f29a32..00000000 --- a/ModuleManager/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/ModuleManagerTests/ModuleManagerTests.csproj b/ModuleManagerTests/ModuleManagerTests.csproj index f0fc3a0a..0edb8b4e 100644 --- a/ModuleManagerTests/ModuleManagerTests.csproj +++ b/ModuleManagerTests/ModuleManagerTests.csproj @@ -1,175 +1,56 @@ - - - - - - + + - Debug - AnyCPU - {BC2A08C8-64EF-4823-A40B-8889C1CCFD75} - Library - Properties + net471 ModuleManagerTests ModuleManagerTests - v4.7.1 - 512 - - - + {BC2A08C8-64EF-4823-A40B-8889C1CCFD75} + 8.0 + false + false + false - - true + + full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - + + pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - 8.0 + - - - ..\packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - - ..\packages\NSubstitute.4.2.2\lib\net46\NSubstitute.dll - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - - - - - - ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll - True - - - ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - {02c8e3af-69f9-4102-ab60-dd6de60662d3} - ModuleManager - - - {20eaafe6-510d-4374-8d2f-6b52d0178e85} - TestUtils - + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - + + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - \ No newline at end of file + + diff --git a/ModuleManagerTests/packages.config b/ModuleManagerTests/packages.config deleted file mode 100644 index b159434d..00000000 --- a/ModuleManagerTests/packages.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TestUtils/TestUtils.csproj b/TestUtils/TestUtils.csproj index 5c53b27c..f2ded3ba 100644 --- a/TestUtils/TestUtils.csproj +++ b/TestUtils/TestUtils.csproj @@ -1,54 +1,32 @@ - - - + + - Debug - AnyCPU - {20EAAFE6-510D-4374-8D2F-6B52D0178E85} - Library - Properties + net471 TestUtils TestUtils - v4.7.1 - 512 - + {20EAAFE6-510D-4374-8D2F-6B52D0178E85} + 8.0 + false + false + false - - true + + full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - + + pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - 8.0 + - - - - - - - + + - - - + + - - \ No newline at end of file + + diff --git a/TestUtilsTests/TestUtilsTests.csproj b/TestUtilsTests/TestUtilsTests.csproj index cfe71bf2..2dd82b99 100644 --- a/TestUtilsTests/TestUtilsTests.csproj +++ b/TestUtilsTests/TestUtilsTests.csproj @@ -1,98 +1,48 @@ - - - - - - + + - Debug - AnyCPU - {E695C11F-4217-4014-9B51-7232A654C205} - Library - Properties + net471 TestUtilsTests TestUtilsTests - v4.7.1 - 512 - - - + {E695C11F-4217-4014-9B51-7232A654C205} + 8.0 + false + false + false - - true + + full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - + + pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - 8.0 + - - - - - - - - - ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll - True - - - ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll - - - - - - - + + - - - - - {20eaafe6-510d-4374-8d2f-6b52d0178e85} - TestUtils - + + + - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - \ No newline at end of file + + diff --git a/TestUtilsTests/packages.config b/TestUtilsTests/packages.config deleted file mode 100644 index 8cf69e4f..00000000 --- a/TestUtilsTests/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file From a6670881dc32be598a04d1a0625f908f2279eb9f Mon Sep 17 00:00:00 2001 From: Sarbian Date: Sun, 29 Nov 2026 12:21:19 +0100 Subject: [PATCH 2/2] Build in the ksp-ci container, with dotnet restore and msbuild The build job runs in ghcr.io/sarbian/ksp-ci (pinned by digest), which has Mono and the .NET SDK 10.0, instead of installing Mono from the mono-project repository on every run. That repository only had focal packages, which kept the job pinned to ubuntu-24.04. With SDK-style projects, the build is dotnet restore and dotnet msbuild, as in MechJeb2: the only download left is KSPLibs. --- .github/workflows/build.yml | 47 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a283f87c..d8f862d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,10 +44,18 @@ defaults: jobs: build: - # Pinned: Mono's repository only has packages built for Ubuntu 20.04 (focal), known to install - # on 24.04. ubuntu-latest moved to 26.04, which also dropped apt-key. - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest timeout-minutes: 20 + # Mono and the .NET SDK come with the job container (https://github.com/sarbian/KSP_CI), so + # no packages are installed here. Pinned by digest: the 26.04 tag is pushed again on each change + # of the image, so a release builds with the image this file names. To update: + # docker buildx imagetools inspect ghcr.io/sarbian/ksp-ci:26.04 (the index Digest) + container: + image: ghcr.io/sarbian/ksp-ci:26.04@sha256:8d6ab6ddd9c79f029b51a9edb57bc0f081492fe426581630dc0253f405f2a590 + options: --user 1001:1001 # the image's unprivileged runner user, as on GitHub's hosted runners + env: + DOTNET_NOLOGO: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 permissions: contents: read pull-requests: write # comment the build on the PR @@ -59,23 +67,10 @@ jobs: with: ref: ${{ inputs.ref }} - # The project is a legacy (non-SDK) net471 csproj built with Mono's own MSBuild, exactly - # like the old Jenkins job did (its "mono-msbuild" tool). Ubuntu's own mono-complete package - # only ships the deprecated xbuild, not msbuild, so we pull Mono from the official repo. - # The signing key goes in its own keyring, named by the source (signed-by), as apt-key is - # gone from newer Ubuntu releases. - - name: Install Mono + - name: Tool versions run: | - sudo apt-get install -y -qq gnupg ca-certificates curl - sudo install -d -m 0755 /etc/apt/keyrings - curl -fsSL --retry 5 --retry-all-errors --retry-delay 5 \ - "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" \ - | sudo gpg --batch --yes --dearmor -o /etc/apt/keyrings/mono-official-stable.gpg - echo "deb [signed-by=/etc/apt/keyrings/mono-official-stable.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list - sudo apt-get update -qq - sudo apt-get install -y -qq mono-devel nuget mono --version | head -1 - msbuild --version | tail -1 + dotnet --version # Compile-only KSP/Unity reference assemblies (method bodies stripped), just enough to # resolve the bare etc. in the csproj files. @@ -115,16 +110,20 @@ jobs: sed -i -E "s/(AssemblyVersion\(\")[^\"]*(\"\))/\1${VERSION}\2/" "$file" grep -qF "AssemblyVersion(\"$VERSION\")" "$file" + # SDK-style net471 projects: the restore also brings the .NET Framework reference assemblies + # (Microsoft.NETFramework.ReferenceAssemblies.net471, see Directory.Build.targets) - name: Restore - run: nuget restore ModuleManager.sln -Verbosity quiet + run: dotnet restore ModuleManager.sln + # ReferencePath resolves the bare KSP/Unity references (see Directory.Build.targets); + # CopyBuild=false skips the copy into a KSP install (copy_build.sh) - name: Build run: > - msbuild ModuleManager.sln - /p:Configuration=Release - /p:ReferencePath=/tmp/ksp/KSP_x64_Data/Managed - /p:PostBuildEvent= - /nologo /v:minimal + dotnet msbuild ModuleManager.sln + -p:Configuration=Release + -p:ReferencePath=/tmp/ksp/KSP_x64_Data/Managed + -p:CopyBuild=false + -nologo -v:minimal - name: Package env: