Skip to content

Commit

Permalink
Update from .NET 5 to .NET 7
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 13, 2023
1 parent 38d8f6f commit 41317ed
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
types:
- opened
- synchronize
- reopened

jobs:
build:
Expand All @@ -14,8 +17,14 @@ jobs:
strategy:
fail-fast: false
matrix:
mono: ['6.8', '6.10', '6.12', 'latest']
configuration: [Debug, Release]
mono:
- latest
- '6.12'
- '6.10'
- '6.8'
configuration:
- Debug
- Release

container:
image: mono:${{ matrix.mono }}
Expand Down Expand Up @@ -66,7 +75,7 @@ jobs:
curl -O https://raw.githubusercontent.com/KSP-CKAN/NetKAN/master/NetKAN/ZeroMiniAVC.netkan && \
mono netkan.exe ZeroMiniAVC.netkan
"
if: matrix.configuration == 'release' && ( matrix.mono == '6.8' || matrix.mono == 'latest' )
if: matrix.configuration == 'release'

- name: Upload ckan.exe artifact
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -95,14 +104,16 @@ jobs:
strategy:
fail-fast: false
matrix:
configuration: [Debug_NetCore, Release_NetCore]
configuration:
- Debug_NetCore
- Release_NetCore

steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '5.0.x'
dotnet-version: '7'
- name: Restore cache for _build/tools
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions Core/CKAN-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Choose>
<When Condition="$(Configuration.EndsWith('NetCore'))">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</When>
<Otherwise>
Expand Down Expand Up @@ -51,7 +51,7 @@
<Reference Include="System.Transactions" />
<Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="System.Security.Permissions" Version="4.7.0" />
Expand Down
4 changes: 4 additions & 0 deletions Core/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public static TimeSpan Sum(this IEnumerable<TimeSpan> source)
public static IEnumerable<V> ZipMany<T, U, V>(this IEnumerable<T> seq1, IEnumerable<U> seq2, Func<T, U, IEnumerable<V>> func)
=> seq1.Zip(seq2, func).SelectMany(seqs => seqs);

#if NET45

/// <summary>
/// Eliminate duplicate elements based on the value returned by a callback
/// </summary>
Expand All @@ -126,6 +128,8 @@ public static IEnumerable<V> ZipMany<T, U, V>(this IEnumerable<T> seq1, IEnumera
public static IEnumerable<T> DistinctBy<T, U>(this IEnumerable<T> seq, Func<T, U> func)
=> seq.GroupBy(func).Select(grp => grp.First());

#endif

/// <summary>
/// Generate a sequence from a linked list
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Choose>
<When Condition="$(Configuration.EndsWith('NetCore'))">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</When>
<Otherwise>
Expand All @@ -30,7 +30,7 @@
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<DefaultItemExcludes>$(DefaultItemExcludes);NetKAN\**;CmdLine\**;ConsoleUI\**;GUI\**;AutoUpdate\**</DefaultItemExcludes>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug_NetCore' ">
Expand Down Expand Up @@ -58,7 +58,7 @@
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
</ItemGroup>
<ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#addin "nuget:?package=Cake.SemVer&version=4.0.0"
#addin "nuget:?package=semver&version=2.0.6"
#addin "nuget:?package=Cake.Docker&version=0.11.0"
#addin "nuget:?package=semver&version=2.3.0"
#addin "nuget:?package=Cake.Docker&version=0.11.1"
#tool "nuget:?package=ILRepack&version=2.0.18"
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.12.0"
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.16.3"

using System.Text.RegularExpressions;
using Semver;

var buildNetCore = "net5.0";
var buildNetCore = "net7.0";
var buildNetFramework = "net45";

var target = Argument<string>("target", "Default");
Expand Down Expand Up @@ -227,7 +227,7 @@ Task("Restore-DotNetCore")

Task("Build-DotNetCore")
.Description("Intermediate - Call .NET Core's MSBuild to build the ckan.dll.")
.IsDependentOn("Restore-Dotnetcore")
.IsDependentOn("Restore-DotNetCore")
.IsDependentOn("Generate-GlobalAssemblyVersionInfo")
.WithCriteria(() => buildFramework == buildNetCore)
.Does(() =>
Expand Down Expand Up @@ -440,7 +440,7 @@ Teardown(context =>

RunTarget(target);

private SemVersion GetVersion()
private Semver.SemVersion GetVersion()
{
var pattern = new Regex(@"^\s*##\s+v(?<version>\S+)\s?.*$");
var rootDirectory = Context.Environment.WorkingDirectory;
Expand Down

0 comments on commit 41317ed

Please sign in to comment.