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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'
- name: Restore
run: dotnet restore
- name: Build
Expand All @@ -30,14 +30,14 @@ jobs:
working-directory: src/openlauncher
run: dotnet publish -c Release -r ${{ matrix.rid }} --self-contained
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: "OpenLauncher-${{ matrix.rid }}"
path: src/openlauncher/bin/Release/net7.0/${{ matrix.rid }}/publish/**/*
path: src/openlauncher/bin/Release/net8.0/${{ matrix.rid }}/publish/**/*
- name: Create release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
src/openlauncher/bin/Release/net7.0/${{ matrix.rid }}/publish/openlauncher
src/openlauncher/bin/Release/net7.0/${{ matrix.rid }}/publish/openlauncher.exe
src/openlauncher/bin/Release/net8.0/${{ matrix.rid }}/publish/openlauncher
src/openlauncher/bin/Release/net8.0/${{ matrix.rid }}/publish/openlauncher.exe
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/openlauncher/bin/Debug/net7.0/openlauncher.dll",
"program": "${workspaceFolder}/src/openlauncher/bin/Debug/net8.0/openlauncher.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ A launcher for automatically downloading the latest, or specific versions of [Op

# 🔨 Building

**Open Launcher** is written in C# using the [AvaloniaUI](http://avaloniaui.net) framework. The application currently targets [.NET 6](https://dotnet.microsoft.com) and is typically distributed as a self contained executable.
**Open Launcher** is written in C# using the [AvaloniaUI](http://avaloniaui.net) framework. The application currently targets [.NET 8](https://dotnet.microsoft.com) and is typically distributed as a self contained executable.

### Prerequisites
* [.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
* [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
* [Visual Studio](https://visualstudio.microsoft.com) (optional)
* [AvaloniaUI extension](https://marketplace.visualstudio.com/items?itemName=AvaloniaTeam.AvaloniaVS) (optional)
* [Visual Studio Code](https://code.visualstudio.com) (optional)
Expand Down
6 changes: 5 additions & 1 deletion src/IntelOrca.OpenLauncher.Core/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ public Version? ParsedVersion

public override string ToString() => Version;

public int CompareTo(Build other)
public int CompareTo(Build? other)
{
ArgumentNullException.ThrowIfNull(other);

var a = PublishedAt;
var b = other.PublishedAt;

if (a is null && b is null)
return 0;
if (a is null)
return 1;
if (b is null)
return -1;

return b.Value.CompareTo(a.Value);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/IntelOrca.OpenLauncher.Core/BuildAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,13 @@ public class BuildAssetComparer : IComparer<BuildAsset>

public static BuildAssetComparer Default = new BuildAssetComparer();

public int Compare(BuildAsset x, BuildAsset y)
public int Compare(BuildAsset? x, BuildAsset? y)
{
if (x == null || y == null)
{
throw new ArgumentNullException("BuildAsset objects cannot be null");
}

if (x.Platform == y.Platform)
{
if (x.Arch != y.Arch)
Expand Down
8 changes: 6 additions & 2 deletions src/IntelOrca.OpenLauncher.Core/InstallService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace IntelOrca.OpenLauncher.Core
{
Expand Down Expand Up @@ -73,12 +74,15 @@ public Task Launch()
{
RedirectStandardError = true
};
var process = Process.Start(psi);

var process = Process.Start(psi) ?? throw new InvalidOperationException($"Failed to start process '{psi}'");

var outputBuilder = new StringBuilder();
var sw = Stopwatch.StartNew();

while (sw.ElapsedMilliseconds < 2000)
{
var s = process.StandardError.ReadToEnd();
string? s = process.StandardError.ReadToEnd();
if (s != null)
outputBuilder.Append(s);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
Comment thread
IntelOrca marked this conversation as resolved.
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Octokit" Version="0.51.0" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/IntelOrca.OpenLauncher.Core/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public int RunProcess(string name, params string[] args)
{
psi.ArgumentList.Add(arg);
}
var p = Process.Start(psi);
var p = Process.Start(psi) ?? throw new InvalidOperationException($"Failed to start process '{name}'");
p.WaitForExit();
return p.ExitCode;
}
Expand Down
11 changes: 7 additions & 4 deletions src/openlauncher/openlauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<!--Avalonia doesen't support TrimMode=link currently,but we are working on that https://github.com/AvaloniaUI/Avalonia/issues/6892 -->
Expand All @@ -18,6 +18,9 @@
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<ApplicationIcon>resources\logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand All @@ -42,10 +45,10 @@
<ProjectReference Include="..\IntelOrca.OpenLauncher.Core\IntelOrca.OpenLauncher.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="0.10.22" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.22" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.22" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />
</ItemGroup>
<ItemGroup>
Expand Down
22 changes: 13 additions & 9 deletions test/IntelOrca.OpenLauncher.Tests/BuildServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ namespace IntelOrca.OpenLauncher.Tests
{
public class BuildServiceTests
{
[Fact]
public async Task GetBuildsAsync_OpenLoco_v22_05_1()
[Theory]
[InlineData("macos", "v22.05.1", 4157592, "2022-05-17T20:06:15Z")]
public async Task GetBuildsAsync_OpenLoco_v22_05_1(string system, string version, int size, string publishtime)
{
var buildService = new BuildService();
var builds = await buildService.GetBuildsAsync(Game.OpenLoco, includeDevelop: false);
var build = builds.First(x => x.Version == "v22.05.1");
Assert.Equal("v22.05.1", build.Version);
Assert.Equal(new DateTime(2022, 5, 17, 20, 6, 15), build.PublishedAt);
Assert.Equal("OpenLoco-v22.05.1-macos.zip", build.Assets[0].Name);
Assert.Equal(new Uri("https://github.com/OpenLoco/OpenLoco/releases/download/v22.05.1/OpenLoco-v22.05.1-macos.zip"), build.Assets[0].Uri);
Assert.Equal("application/x-zip-compressed", build.Assets[0].ContentType);
Assert.Equal(4157592, build.Assets[0].Size);
var build = builds.First(x => x.Version == version && x.Assets.Any(t => IsMatchingSystemAsset(system, t)));

Assert.Equal(version, build.Version);
Assert.Equal(DateTime.Parse(publishtime).ToUniversalTime(), build.PublishedAt);
Assert.Equal($"OpenLoco-{version}-{system}.zip", build.Assets.Where(t => IsMatchingSystemAsset(system, t)).First().Name);
Assert.Equal(new Uri($"https://github.com/OpenLoco/OpenLoco/releases/download/{version}/OpenLoco-{version}-{system}.zip"), build.Assets.Where(t => t.Uri.AbsoluteUri.Contains("macos.zip")).First().Uri);
Assert.Equal("application/x-zip-compressed", build.Assets.Where(t => IsMatchingSystemAsset(system, t)).First().ContentType);
Assert.Equal(size, build.Assets.Where(t => IsMatchingSystemAsset(system, t)).First().Size);
}

private static bool IsMatchingSystemAsset(string system, BuildAsset t) => t.Uri.AbsoluteUri.Contains($"{system}.zip");
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down