Skip to content

Commit eab98a6

Browse files
Merge pull request #24 from LavaGang/development
Installer v4.0.0
2 parents e8e1af8 + e73bab8 commit eab98a6

26 files changed

Lines changed: 280 additions & 128 deletions

.github/workflows/build-final.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build Installer Final
2+
3+
run-name: Final Build
4+
5+
on:
6+
push:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
name: Build Installer
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Setup dotnet
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: 9.0.x
19+
20+
- name: Build
21+
run: dotnet publish
22+
23+
- name: Upload Artifact
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: MelonLoader.Installer
27+
path: Output/win-x64/

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build Installer
2+
3+
run-name: 4.0.0-ci.${{ github.run_number }} | ${{ github.event_name != 'workflow_dispatch' && (github.event.head_commit.message || format('`[PR]` {0}', github.event.pull_request.title)) || 'Manual Build' }}
4+
5+
env:
6+
DEVVERSION: "4.0.0"
7+
8+
on:
9+
push:
10+
branches: [ development ]
11+
pull_request:
12+
branches: [ development ]
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
name: Build Installer
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Setup dotnet
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: 9.0.x
25+
26+
- name: Build
27+
run: dotnet publish -p:Version="${{ env.DEVVERSION }}.${{ github.run_number }}"
28+
29+
- name: Upload Artifact
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: MelonLoader.Installer
33+
path: Output/win-x64/

Directory.Build.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<Project>
2-
<PropertyGroup>
3-
<Nullable>enable</Nullable>
4-
<AvaloniaVersion>11.2.1</AvaloniaVersion>
5-
</PropertyGroup>
6-
</Project>
2+
<PropertyGroup>
3+
<Version>4.0.0</Version>
4+
5+
<Nullable>enable</Nullable>
6+
<AvaloniaVersion>11.2.1</AvaloniaVersion>
7+
</PropertyGroup>
8+
</Project>

MelonLoader.Installer/App.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace MelonLoader.Installer;
1111

12-
public partial class App : Application
12+
public class App : Application
1313
{
1414
public override void Initialize()
1515
{

MelonLoader.Installer/InstallerUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class InstallerUtils
99
static InstallerUtils()
1010
{
1111
Http = new();
12-
Http.DefaultRequestHeaders.Add("User-Agent", $"MelonLoader Installer v{Program.Version.ToString(3)}");
12+
Http.DefaultRequestHeaders.Add("User-Agent", $"MelonLoader Installer v{Program.VersionName}");
1313
}
1414

1515
public static async Task<string?> DownloadFileAsync(string url, Stream destination, InstallProgressEventHandler? onProgress)

MelonLoader.Installer/MLManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private static async Task<bool> GetVersionsAsync(List<MLVersion> versions)
8181

8282
try
8383
{
84-
resp = await InstallerUtils.Http.GetAsync(run!["artifacts_url"]!.ToString()).ConfigureAwait(false);
84+
resp = await InstallerUtils.Http.GetAsync(run["artifacts_url"]!.ToString()).ConfigureAwait(false);
8585
}
8686
catch
8787
{
@@ -387,7 +387,7 @@ void SetProgress(double progress, string? newStatus = null)
387387
onProgress?.Invoke(currentTask / (double)tasks + progress / tasks, newStatus);
388388
}
389389

390-
SetProgress(0, "Downloading MelonLoader " + version.ToString());
390+
SetProgress(0, "Downloading MelonLoader " + version);
391391

392392
using var bufferStr = new MemoryStream();
393393
var result = await InstallerUtils.DownloadFileAsync(downloadUrl, bufferStr, SetProgress);
@@ -400,7 +400,7 @@ void SetProgress(double progress, string? newStatus = null)
400400

401401
currentTask++;
402402

403-
SetProgress(0, "Installing " + version.ToString());
403+
SetProgress(0, "Installing " + version);
404404

405405
var extRes = InstallerUtils.Extract(bufferStr, gameDir, SetProgress);
406406
if (extRes != null)

MelonLoader.Installer/MelonLoader.Installer.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<LangVersion>latest</LangVersion>
1111
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
1212
<ApplicationIcon>Assets/icon.ico</ApplicationIcon>
13-
<PublishDir>../Output/win-x64</PublishDir>
13+
<PublishDir>../Output/$(RuntimeIdentifier)</PublishDir>
1414
<PublishSingleFile>true</PublishSingleFile>
1515
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
1616
<DebugType>embedded</DebugType>
@@ -21,8 +21,6 @@
2121

2222
<Authors>Lava Gang</Authors>
2323
<Company>discord.gg/2Wn3N2P</Company>
24-
25-
<Version>4.0.0</Version>
2624
</PropertyGroup>
2725

2826
<ItemGroup>

MelonLoader.Installer/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ internal static class Program
99

1010
public static event Action? Exiting;
1111

12-
public static Version Version { get; private set; } = typeof(Program).Assembly.GetName().Version!;
12+
public static Version Version { get; } = typeof(Program).Assembly.GetName().Version!;
13+
14+
public static string VersionName { get; } =
15+
$"v{Version.Major}.{Version.Minor}.{Version.Build}{(Version.Revision > 0 ? $"-ci.{Version.Revision}" : string.Empty)}";
1316

1417
// Initialization code. Don't use any Avalonia, third-party APIs or any
1518
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
@@ -69,11 +72,8 @@ private static bool CheckProcessLock()
6972

7073
var procId = BitConverter.ToInt32(procIdRaw);
7174
var proc = Process.GetProcessById(procId);
72-
if (proc != null)
73-
{
74-
GrabAttention(proc);
75-
return false;
76-
}
75+
GrabAttention(proc);
76+
return false;
7777
}
7878
catch { return false; }
7979
}

MelonLoader.Installer/Updater.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public static class Updater
1313

1414
public static bool UpdateIfPossible()
1515
{
16+
// Don't auto-update on CI builds
17+
if (Program.Version.Revision > 0)
18+
return false;
19+
1620
var downloadUrl = CheckForUpdateAsync().GetAwaiter().GetResult();
1721
if (downloadUrl == null)
1822
return false;
@@ -87,11 +91,7 @@ private static async Task UpdateAsync(string downloadUrl)
8791
}
8892
}
8993

90-
if (Process.Start(newPath, ["-handleupdate", Environment.ProcessPath!, Environment.ProcessId.ToString()]) == null)
91-
{
92-
Finish("Failed to start the new installer.");
93-
return;
94-
}
94+
Process.Start(newPath, ["-handleupdate", Environment.ProcessPath!, Environment.ProcessId.ToString()]);
9595

9696
Finish(null);
9797
}
@@ -101,8 +101,8 @@ public static bool CheckLegacyUpdate()
101101
if (!Environment.ProcessPath!.EndsWith(".tmp.exe", StringComparison.OrdinalIgnoreCase))
102102
return false;
103103

104-
var dir = Path.GetDirectoryName(Environment.ProcessPath!)!;
105-
var name = Path.GetFileNameWithoutExtension(Environment.ProcessPath!);
104+
var dir = Path.GetDirectoryName(Environment.ProcessPath)!;
105+
var name = Path.GetFileNameWithoutExtension(Environment.ProcessPath);
106106
name = name.Remove(name.Length - 4) + ".exe";
107107

108108
var final = Path.Combine(dir, name);

MelonLoader.Installer/ViewModels/DetailsViewModel.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
public class DetailsViewModel(GameModel game) : ViewModelBase
44
{
55
private bool _installing;
6-
private bool _confirmation;
76
private bool _offline;
87

98
public GameModel Game => game;
@@ -14,34 +13,21 @@ public bool Installing
1413
set
1514
{
1615
_installing = value;
17-
OnPropertyChanged(nameof(Installing));
18-
OnPropertyChanged(nameof(CanInstall));
16+
OnPropertyChanged();
1917
OnPropertyChanged(nameof(EnableSettings));
2018
}
2119
}
2220

23-
public bool Confirmation
24-
{
25-
get => _confirmation;
26-
set
27-
{
28-
_confirmation = value;
29-
OnPropertyChanged(nameof(Confirmation));
30-
OnPropertyChanged(nameof(CanInstall));
31-
}
32-
}
33-
3421
public bool Offline
3522
{
3623
get => _offline;
3724
set
3825
{
3926
_offline = value;
40-
OnPropertyChanged(nameof(Confirmation));
27+
OnPropertyChanged();
4128
OnPropertyChanged(nameof(EnableSettings));
4229
}
4330
}
4431

45-
public bool CanInstall => !Installing && !Confirmation;
4632
public bool EnableSettings => !Offline && !Installing;
4733
}

0 commit comments

Comments
 (0)