Skip to content

Commit 14edc67

Browse files
authored
Re-enable support for packages.config style projects in next (#68)
This requires setting the `use-nuget-restore` option on the compile action/build workflow.
1 parent 09427ed commit 14edc67

File tree

11 files changed

+166
-3
lines changed

11 files changed

+166
-3
lines changed

.github/actions/compile/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ inputs:
3636
default: ${{ github.workspace }}
3737
description: the working directory to run in
3838

39+
use-nuget-restore:
40+
default: 'false'
41+
description: >
42+
Set to true if your project uses a packages.config file instead of packagereferences. Ensure the environment has
43+
nuget and mono installed, either installing them manually or by using the Github Ubuntu-22.04 images
44+
3945
runs:
4046
using: composite
4147
steps:
@@ -68,9 +74,16 @@ runs:
6874
6975
- name: Restore Mod Solution
7076
shell: bash
77+
if: ${{ inputs.use-nuget-restore != 'true'}} # https://github.com/actions/runner/issues/1483 :sufferbeale:
7178
working-directory: ${{ inputs.working-directory }}
7279
run: dotnet restore ${{ inputs.solution-file-path }} ${{ runner.debug && '-v:diagnostic' }}
7380

81+
- name: Restore Mod Solution (NuGet)
82+
shell: bash
83+
if: ${{ inputs.use-nuget-restore == 'true'}}
84+
working-directory: ${{ inputs.working-directory }}
85+
run: nuget restore ${{ inputs.solution-file-path }} -Verbosity detailed
86+
7487
- name: Build Mod Solution
7588
shell: bash
7689
working-directory: ${{ inputs.working-directory }}

.github/workflows/build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ on:
2222
description: >
2323
If MSBuild should be used. If your mod has no msbuild project (e.g. a pure part mod)
2424
you should set this to false
25+
use-nuget-restore:
26+
type: boolean
27+
default: false
28+
description: >
29+
Set to true if your project uses a packages.config file instead of packagereferences. This will cause the job
30+
to run on the Ubuntu-22.04 image instead of Ubuntu-24.04
2531
use-ckan:
2632
type: boolean
2733
default: false
@@ -37,7 +43,7 @@ defaults:
3743

3844
jobs:
3945
build:
40-
runs-on: ubuntu-22.04
46+
runs-on: ${{ inputs.use-nuget-restore && 'ubuntu-22.04' || 'ubuntu-24.04' }}
4147
steps:
4248
- name: Checkout Mod Repo
4349
uses: actions/checkout@v4
@@ -62,6 +68,7 @@ jobs:
6268
ksp-zip-url: ${{ inputs.ksp-zip-url }}
6369
ksp-zip-password: ${{ secrets.ksp-zip-password }}
6470
solution-file-path: ${{ inputs.solution-file-path }}
71+
use-nuget-restore: ${{ inputs.use-nuget-restore }}
6572

6673
# Assemble the mod into a release package and upload it as an artifact
6774
- uses: KSPModdingLibs/KSPBuildTools/.github/actions/[email protected]

.github/workflows/internal-ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ jobs:
6565
with:
6666
package-version: ${{ needs.build.outputs.package-version }}
6767

68+
test-plugin-legacy:
69+
uses: './.github/workflows/internal-test-plugin-legacy.yml'
70+
6871
test-assetbundle:
6972
uses: './.github/workflows/internal-test-assetbundle.yml'
7073
if: github.event_name != 'pull_request'
7174
secrets: inherit
7275

7376
deploy:
7477
runs-on: ubuntu-22.04
75-
needs: [ build, test-plugin, test-plugin-nuget, test-assetbundle ]
78+
needs: [ build, test-plugin, test-plugin-nuget, test-plugin-legacy, test-assetbundle ]
7679
environment:
7780
name: "NuGet"
7881
url: "https://www.nuget.org/packages/KSPBuildTools"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This is an internal test for KSPBuildTools and not intended to be used by other projects
2+
name: Test Plugin Mod (Legacy)
3+
4+
on:
5+
workflow_call:
6+
7+
env:
8+
TESTDIR: tests/plugin-mod-legacy
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: ./.github/actions/setup-ckan
17+
18+
- uses: ./.github/actions/compile
19+
with:
20+
ksp-zip-url: https://github.com/KSPModdingLibs/KSPLibs/raw/main/KSP-1.12.5.zip
21+
working-directory: ${{ env.TESTDIR }}
22+
use-nuget-restore: true
23+
24+
- uses: ./.github/actions/assemble-release
25+
with:
26+
artifacts: ${{ env.TESTDIR }}/GameData
27+
output-file-name: plugin-mod-legacy

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file
2828

2929
### Actions
3030

31+
- Added the `use-nuget-restore` option to the `compile` action to use the `nuget restore` command, for projects using packages.config files. This allows the `compile` action with default settings to work on any Ubuntu runner image
3132
- Sped up `setup-ckan` action by skipping recommended packages and man-db updates
3233

3334

docs/actions/compile.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
```{warning}
77
Due to the [handover of the Mono project](https://github.com/mono/mono/issues/21796), the `ubuntu-latest` github runner [does not currently include mono or nuget](https://github.com/actions/runner-images/issues/10636#issuecomment-2375010324).
88
9-
Please use the `ubuntu-22.04` runner for this action.
9+
Please use the `ubuntu-22.04` runner image or install nuget yourself when `use-nuget-restore` is not `'true'`.
10+
11+
This does not affect projects that use `packagereference`
1012
```
1113
1214
````

tests/plugin-mod-legacy/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
packages
2+
obj
3+
bin
4+
GameData
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "plugin-mod-legacy", "PluginModLegacy\plugin-mod-legacy.csproj", "{F19C7AB4-50C2-4378-9673-CC039CA12E10}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
// Information about this assembly is defined by the following attributes.
5+
// Change them to the values specific to your project.
6+
[assembly: AssemblyTitle ("PluginModLegacy")]
7+
[assembly: AssemblyDescription ("Test mod using a legacy csproj")]
8+
9+
// This supposedly helps avoid plugin depencency problems.
10+
[assembly: KSPAssembly("plugin-mod-legacy", 1, 2, 3)]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Krafs.Publicizer" version="1.0.3" targetFramework="net48" developmentDependency="true" />
4+
</packages>

0 commit comments

Comments
 (0)