Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/actions/compile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ inputs:
default: ${{ github.workspace }}
description: the working directory to run in

use-nuget-restore:
default: 'false'
description: >
Set to true if your project uses a packages.config file instead of packagereferences. Ensure the environment has
nuget and mono installed, either installing them manually or by using the Github Ubuntu-22.04 images

runs:
using: composite
steps:
Expand Down Expand Up @@ -68,9 +74,16 @@ runs:

- name: Restore Mod Solution
shell: bash
if: ${{ inputs.use-nuget-restore != 'true'}} # https://github.com/actions/runner/issues/1483 :sufferbeale:
working-directory: ${{ inputs.working-directory }}
run: dotnet restore ${{ inputs.solution-file-path }} ${{ runner.debug && '-v:diagnostic' }}

- name: Restore Mod Solution (NuGet)
shell: bash
if: ${{ inputs.use-nuget-restore == 'true'}}
working-directory: ${{ inputs.working-directory }}
run: nuget restore ${{ inputs.solution-file-path }} -Verbosity detailed

- name: Build Mod Solution
shell: bash
working-directory: ${{ inputs.working-directory }}
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ on:
description: >
If MSBuild should be used. If your mod has no msbuild project (e.g. a pure part mod)
you should set this to false
use-nuget-restore:
type: boolean
default: false
description: >
Set to true if your project uses a packages.config file instead of packagereferences. This will cause the job
to run on the Ubuntu-22.04 image instead of Ubuntu-24.04
use-ckan:
type: boolean
default: false
Expand All @@ -37,7 +43,7 @@ defaults:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ${{ inputs.use-nuget-restore && 'ubuntu-22.04' || 'ubuntu-24.04' }}
steps:
- name: Checkout Mod Repo
uses: actions/checkout@v4
Expand All @@ -62,6 +68,7 @@ jobs:
ksp-zip-url: ${{ inputs.ksp-zip-url }}
ksp-zip-password: ${{ secrets.ksp-zip-password }}
solution-file-path: ${{ inputs.solution-file-path }}
use-nuget-restore: ${{ inputs.use-nuget-restore }}

# Assemble the mod into a release package and upload it as an artifact
- uses: KSPModdingLibs/KSPBuildTools/.github/actions/[email protected]
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/internal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ jobs:
with:
package-version: ${{ needs.build.outputs.package-version }}

test-plugin-legacy:
uses: './.github/workflows/internal-test-plugin-legacy.yml'

test-assetbundle:
uses: './.github/workflows/internal-test-assetbundle.yml'
if: github.event_name != 'pull_request'
secrets: inherit

deploy:
runs-on: ubuntu-22.04
needs: [ build, test-plugin, test-plugin-nuget, test-assetbundle ]
needs: [ build, test-plugin, test-plugin-nuget, test-plugin-legacy, test-assetbundle ]
environment:
name: "NuGet"
url: "https://www.nuget.org/packages/KSPBuildTools"
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/internal-test-plugin-legacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This is an internal test for KSPBuildTools and not intended to be used by other projects
name: Test Plugin Mod (Legacy)

on:
workflow_call:

env:
TESTDIR: tests/plugin-mod-legacy

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-ckan

- uses: ./.github/actions/compile
with:
ksp-zip-url: https://github.com/KSPModdingLibs/KSPLibs/raw/main/KSP-1.12.5.zip
working-directory: ${{ env.TESTDIR }}
use-nuget-restore: true

- uses: ./.github/actions/assemble-release
with:
artifacts: ${{ env.TESTDIR }}/GameData
output-file-name: plugin-mod-legacy
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file

### Actions

- 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
- Sped up `setup-ckan` action by skipping recommended packages and man-db updates


Expand Down
4 changes: 3 additions & 1 deletion docs/actions/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
```{warning}
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).

Please use the `ubuntu-22.04` runner for this action.
Please use the `ubuntu-22.04` runner image or install nuget yourself when `use-nuget-restore` is not `'true'`.

This does not affect projects that use `packagereference`
```

````
4 changes: 4 additions & 0 deletions tests/plugin-mod-legacy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages
obj
bin
GameData
22 changes: 22 additions & 0 deletions tests/plugin-mod-legacy/PluginModLegacy.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "plugin-mod-legacy", "PluginModLegacy\plugin-mod-legacy.csproj", "{F19C7AB4-50C2-4378-9673-CC039CA12E10}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions tests/plugin-mod-legacy/PluginModLegacy/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("PluginModLegacy")]
[assembly: AssemblyDescription ("Test mod using a legacy csproj")]

// This supposedly helps avoid plugin depencency problems.
[assembly: KSPAssembly("plugin-mod-legacy", 1, 2, 3)]
4 changes: 4 additions & 0 deletions tests/plugin-mod-legacy/PluginModLegacy/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Krafs.Publicizer" version="1.0.3" targetFramework="net48" developmentDependency="true" />
</packages>
70 changes: 70 additions & 0 deletions tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)../packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.props" Condition="Exists('$(MSBuildThisFileDirectory)../packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F19C7AB4-50C2-4378-9673-CC039CA12E10}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>JSI</RootNamespace>
<AssemblyName>PluginModMono</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<CodePage>65001</CodePage>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Profile|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Profile\</OutputPath>
<DefineConstants>ENABLE_PROFILER</DefineConstants>
<Optimize>true</Optimize>
<DebugType>portable</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)/$(MSBuildToolsVersion)\Microsoft.Common.props" />
<Import Project="$(MSBuildThisFileDirectory)../../../KSPCommon.targets" />
<Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="Properties/AssemblyInfo.cs"/>
</ItemGroup>
<ItemGroup>
<Publicize Include="Assembly-CSharp" />
</ItemGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(MSBuildThisFileDirectory)../packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.props')" Text="$([System.String]::Format('$(ErrorText)', '$(MSBuildThisFileDirectory)../packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.props'))" />
<Error Condition="!Exists('$(MSBuildThisFileDirectory)../packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(MSBuildThisFileDirectory)../packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.targets'))" />
</Target>
<Import Project="$(MSBuildThisFileDirectory)../packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.targets" Condition="Exists('$(MSBuildThisFileDirectory)packages/Krafs.Publicizer.1.0.3/build/Krafs.Publicizer.targets')" />
</Project>