Skip to content

Commit

Permalink
Target net8.0 & net48
Browse files Browse the repository at this point in the history
  • Loading branch information
Rans4ckeR committed Dec 24, 2023
1 parent 47f779b commit a2bbf5a
Show file tree
Hide file tree
Showing 42 changed files with 1,859 additions and 980 deletions.
1,588 changes: 1,218 additions & 370 deletions .editorconfig

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
###############################################################################
* text=auto
*.ps1 eol=lf
*.sh eol=lf

###############################################################################
# Set default behavior for command prompt diff.
Expand Down
92 changes: 72 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,87 @@
name: build client

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
workflow_dispatch:
permissions:
contents: write
jobs:
build-clients:
runs-on: windows-2022
calculate-version:
name: Calculate Version
runs-on: windows-latest
outputs:
AssemblySemVer: ${{ steps.gitversion.outputs.AssemblySemVer }}
AssemblySemFileVer: ${{ steps.gitversion.outputs.AssemblySemFileVer }}
InformationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }}
SemVer: ${{ steps.gitversion.outputs.SemVer }}
PreReleaseTag: ${{ steps.gitversion.outputs.PreReleaseTag }}
Sha: ${{ steps.gitversion.outputs.Sha }}
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@main
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@main
publish:
name: Publish
runs-on: windows-latest
needs: calculate-version
env:
AssemblySemVer: ${{ needs.calculate-version.outputs.AssemblySemVer }}
AssemblySemFileVer: ${{ needs.calculate-version.outputs.AssemblySemFileVer }}
InformationalVersion: ${{ needs.calculate-version.outputs.InformationalVersion }}
SemVer: ${{ needs.calculate-version.outputs.SemVer }}
Sha: ${{ needs.calculate-version.outputs.Sha }}
strategy:
matrix:
Game: [Ares,TS,YR]

game: [Ares,TS,YR]
framework: [net8.0, net48]
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@main
with:
fetch-depth: 0

- name: Setup .NET Core SDK
uses: actions/[email protected]
ref: ${{ env.Sha }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@main
with:
dotnet-version: '7.x.x'

- name: Build ${{matrix.Game}}
run: ./BuildScripts/Build-${{matrix.Game}}.ps1
dotnet-version: '8.x.x'
- name: Build ${{matrix.game}}
run: ./BuildScripts/Build-${{matrix.game}}.ps1 Release ${{matrix.framework}} ${{env.AssemblySemVer}} ${{env.AssemblySemFileVer}} ${{env.InformationalVersion}}
shell: pwsh

- uses: actions/[email protected]
name: Upload Artifacts
- name: Zip
run: 7z a -r "${{ format('{0}-v{1}-{2}.zip', matrix.game, env.SemVer, matrix.framework) }}" "./Compiled/${{matrix.game}}/${{matrix.framework}}/*.*" "-x!*.xml"
- name: Upload Artifacts
uses: actions/upload-artifact@main
with:
name: artifacts-${{matrix.Game}}
path: ./Compiled/${{matrix.Game}}

name: ${{matrix.game}}-${{matrix.framework}}
path: ${{ format('{0}-v{1}-{2}.zip', matrix.game, env.SemVer, matrix.framework) }}
if-no-files-found: error
release:
name: Release
if: github.event_name == 'workflow_dispatch'
needs: [calculate-version, publish]
env:
PreReleaseTag: ${{ needs.calculate-version.outputs.PreReleaseTag }}
SemVer: ${{ needs.calculate-version.outputs.SemVer }}
Sha: ${{ needs.calculate-version.outputs.Sha }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
ref: ${{ env.Sha }}
- name: Download Artifacts
uses: actions/download-artifact@main
with:
path: ./artifacts
- name: Release
run: gh release create ${{ format('v{0}', env.SemVer) }} (Get-Item ./artifacts/*/*.zip) --generate-notes --target ${{ github.sha }} ${{ env.PreReleaseTag != '' && '--prerelease' || '' }}
env:
GH_TOKEN: ${{ github.token }}
6 changes: 3 additions & 3 deletions .github/workflows/pr-build-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ on:
jobs:
pr_comment:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6.3.1
- uses: actions/github-script@main
with:
# This snippet is public-domain, taken from
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
Expand Down Expand Up @@ -49,4 +49,4 @@ jobs:
} else {
core.info(`Creating a comment`);
await github.rest.issues.createComment({repo, owner, issue_number, body});
}
}
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ PublishScripts/
*.nupkg
# NuGet Symbol Packages
*.snupkg

# ... with an exception in References folder
!**/[Rr]eferences/*.nupkg
!**/[Rr]eferences/*.snupkg

# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
Expand Down
10 changes: 10 additions & 0 deletions BuildScripts/Build-All-Framework.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env pwsh
#Requires -Version 7.2

param($Configuration = "Release", $Framework = "net8.0", $AssemblySemVer = "0.0.0", $AssemblySemFileVer = "0.0.0.0", $InformationalVersion = "0.0.0-local")

. $PSScriptRoot\Common.ps1

@('Ares', 'TS', 'YR') | ForEach-Object {
. "$PSScriptRoot\Build-$_.ps1" $Configuration $Framework $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
6 changes: 3 additions & 3 deletions BuildScripts/Build-All.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env pwsh
#Requires -Version 7.2

param($Configuration = "Release")
param($Configuration = "Release", $AssemblySemVer = "0.0.0", $AssemblySemFileVer = "0.0.0.0", $InformationalVersion = "0.0.0-local")

. $PSScriptRoot\Common.ps1

@('Ares', 'TS', 'YR') | ForEach-Object {
. "$PSScriptRoot\Build-$_.ps1" $Configuration
@('net8.0', 'net48') | ForEach-Object {
. "$PSScriptRoot\Build-All-Framework.ps1" $Configuration $_ $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
8 changes: 5 additions & 3 deletions BuildScripts/Build-Ares.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env pwsh
#Requires -Version 7.2

param($Configuration = "Release")
param($Configuration = "Release", $Framework = "net8.0", $AssemblySemVer = "0.0.0", $AssemblySemFileVer = "0.0.0.0", $InformationalVersion = "0.0.0-local")

. $PSScriptRoot\Common.ps1

Build-Project $Configuration Ares UniversalGL net7.0
if ($Framework -notlike 'net4*') {
Build-Project $Configuration Ares UniversalGL $Framework $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
if ($IsWindows) {
@('WindowsDX', 'WindowsGL', 'WindowsXNA') | ForEach-Object {
Build-Project $Configuration Ares $_ net48
Build-Project $Configuration Ares $_ $Framework$($Framework -notlike 'net4*' ? '-windows' : '') $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
}
8 changes: 5 additions & 3 deletions BuildScripts/Build-TS.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env pwsh
#Requires -Version 7.2

param($Configuration = "Release")
param($Configuration = "Release", $Framework = "net8.0", $AssemblySemVer = "0.0.0", $AssemblySemFileVer = "0.0.0.0", $InformationalVersion = "0.0.0-local")

. $PSScriptRoot\Common.ps1

Build-Project $Configuration TS UniversalGL net7.0
if ($Framework -notlike 'net4*') {
Build-Project $Configuration TS UniversalGL $Framework $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
if ($IsWindows) {
@('WindowsDX', 'WindowsGL', 'WindowsXNA') | ForEach-Object {
Build-Project $Configuration TS $_ net48
Build-Project $Configuration TS $_ $Framework$($Framework -notlike 'net4*' ? '-windows' : '') $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
}
8 changes: 5 additions & 3 deletions BuildScripts/Build-YR.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env pwsh
#Requires -Version 7.2

param($Configuration = "Release")
param($Configuration = "Release", $Framework = "net8.0", $AssemblySemVer = "0.0.0", $AssemblySemFileVer = "0.0.0.0", $InformationalVersion = "0.0.0-local")

. $PSScriptRoot\Common.ps1

Build-Project $Configuration YR UniversalGL net7.0
if ($Framework -notlike 'net4*') {
Build-Project $Configuration YR UniversalGL $Framework $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
if ($IsWindows) {
@('WindowsDX', 'WindowsGL', 'WindowsXNA') | ForEach-Object {
Build-Project $Configuration YR $_ net48
Build-Project $Configuration YR $_ $Framework$($Framework -notlike 'net4*' ? '-windows' : '') $AssemblySemVer $AssemblySemFileVer $InformationalVersion
}
}
20 changes: 5 additions & 15 deletions BuildScripts/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,17 @@
$RepoRoot = Split-Path $PSScriptRoot -Parent
$ProjectPath = Join-Path $RepoRoot DXMainClient DXMainClient.csproj
$CompiledRoot = Join-Path $RepoRoot Compiled
$EngineSubFolderMap = @{
$EngineMap = @{
'UniversalGL' = 'UniversalGL'
'WindowsDX' = 'Windows'
'WindowsGL' = 'OpenGL'
'WindowsXNA' = 'XNA'
}
$EngineBinariesFolderMap = @{
'UniversalGL' = 'BinariesUGL'
'WindowsDX' = 'Binaries'
'WindowsGL' = 'Binaries'
'WindowsXNA' = 'Binaries'
}

function Build-Project($Configuration, $Game, $Engine, $Framework) {
$Output = Join-Path $CompiledRoot $Game $Output Resources ($EngineBinariesFolderMap[$Engine]) ($EngineSubFolderMap[$Engine])
if ($Engine -EQ 'WindowsXNA') {
dotnet publish $ProjectPath --configuration=$Configuration -property:GAME=$Game -property:ENGINE=$Engine --framework=$Framework --output=$Output --arch=x86
}
else {
dotnet publish $ProjectPath --configuration=$Configuration -property:GAME=$Game -property:ENGINE=$Engine --framework=$Framework --output=$Output
}
function Build-Project($Configuration, $Game, $Engine, $Framework, $AssemblySemVer, $AssemblySemFileVer, $InformationalVersion) {
$Output = Join-Path $CompiledRoot $Game ($Framework -Split "-")[0] $Output Resources Binaries ($EngineMap[$Engine])
dotnet publish $ProjectPath -c $Configuration -p:GAME=$Game -p:ENGINE=$Engine -f $Framework -o $Output -p:SatelliteResourceLanguages=en -p:AssemblyVersion=$AssemblySemVer -p:FileVersion=$AssemblySemFileVer -p:InformationalVersion=$InformationalVersion $($Engine -EQ 'WindowsXNA' ? '--arch=x86' : '')

if ($LASTEXITCODE) {
throw "Build failed for $Game $Engine $Framework $Configuration"
}
Expand Down
3 changes: 2 additions & 1 deletion BuildScripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ TargetFramework configurations
For each Engine configuration one or more TargetFrameworks will be build:

UniversalGL:
* net7.0
* net8.0

WindowsDX, WindowsGL & WindowsXNA:
* net8.0-windows
* net48

Overview of the Engine configurations differences:
Expand Down
33 changes: 13 additions & 20 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Rampastring.Tools;
using System.IO;
Expand Down Expand Up @@ -283,7 +283,11 @@ private List<TranslationGameFile> ParseTranslationGameFiles()
{
// the syntax is GameFileX=path/to/source.file,path/to/destination.file[,checked]
string value = clientDefinitionsIni.GetStringValue(TRANSLATIONS, $"GameFile{i}", string.Empty);
string[] parts = value.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray();
#if NETFRAMEWORK
string[] parts = value.Split(',').Select(q => q.Trim()).ToArray();
#else
string[] parts = value.Split(',', StringSplitOptions.TrimEntries);
#endif

// fail explicitly if the syntax is wrong
if (parts.Length is < 2 or > 3
Expand Down Expand Up @@ -382,10 +386,9 @@ public IEnumerable<string> SupplementalMapFileExtensions

public OSVersion GetOperatingSystemVersion()
{
#if NETFRAMEWORK
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
#if NETFRAMEWORK
// OperatingSystem.IsWindowsVersionAtLeast() is the preferred API but is not supported on earlier .NET versions
Version osVersion = Environment.OSVersion.Version;

if (osVersion.Major < 5)
Expand All @@ -401,24 +404,14 @@ public OSVersion GetOperatingSystemVersion()
return OSVersion.WIN7;

return OSVersion.WIN810;
#else
if (OperatingSystem.IsWindowsVersionAtLeast(6, 3))
return OSVersion.WIN810;

if (OperatingSystem.IsWindowsVersionAtLeast(6, 1))
return OSVersion.WIN7;

return OSVersion.UNKNOWN;
#endif
}

int p = (int)Environment.OSVersion.Platform;

// http://mono.wikia.com/wiki/Detecting_the_execution_platform
if (p == 4 || p == 6 || p == 128)
return OSVersion.UNIX;

return OSVersion.UNKNOWN;
return ProgramConstants.ISMONO ? OSVersion.UNIX : OSVersion.UNKNOWN;
#else
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? OperatingSystem.IsWindowsVersionAtLeast(6, 3) ? OSVersion.WIN810 : OSVersion.WIN7
: OSVersion.UNIX;
#endif
}
}

Expand Down
17 changes: 3 additions & 14 deletions ClientCore/ClientCore.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Title>CnCNet Client</Title>
<Description>CnCNet Client Core Library</Description>
<Company>CnCNet</Company>
<Product>CnCNet Client</Product>
<Copyright>Copyright © CnCNet, Rampastring 2011-2022</Copyright>
<Trademark>CnCNet</Trademark>
<Version>2.0.0.3</Version>
<FileVersion>2.0.0.3</FileVersion>
<InformationalVersion>2.0.0.3</InformationalVersion>
<AssemblyName>ClientCore</AssemblyName>
<RootNamespace>ClientCore</RootNamespace>
</PropertyGroup>
Expand Down Expand Up @@ -45,15 +37,12 @@
<EmbeddedResource Include="Resources\unknownicon.png" />
<EmbeddedResource Include="Resources\yricon.png" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.11.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Rampastring.Tools" Version="2.0.4" />
<PackageReference Include="Rampastring.XNAUI.$(Engine)" Version="2.3.8" Condition="'!$(Configuration.Contains(Debug))'" />
<PackageReference Include="Rampastring.XNAUI.$(Engine).Debug" Version="2.3.8" Condition="'$(Configuration.Contains(Debug))'" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TranslationNotifierGenerator\TranslationNotifierGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
Expand Down
Loading

0 comments on commit a2bbf5a

Please sign in to comment.