- tweak: improve update resolver for further updates
This commit is contained in:
@@ -62,5 +62,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Nebula.Shared\Nebula.Shared.csproj"/>
|
||||
<ProjectReference Include="..\Nebula.SourceGenerators\Nebula.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
|
||||
<ProjectReference Include="..\Nebula.Runner\Nebula.Runner.csproj"
|
||||
ReferenceOutputAssembly="false" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
37
Nebula.Packager/CommandLineParser.cs
Normal file
37
Nebula.Packager/CommandLineParser.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace Nebula.Packager;
|
||||
|
||||
public class CommandLineParser
|
||||
{
|
||||
public string Configuration { get; set; } = "Release";
|
||||
public string RootPath { get; set; } = string.Empty;
|
||||
|
||||
public static CommandLineParser Parse(IReadOnlyList<string> args)
|
||||
{
|
||||
using var enumerator = args.GetEnumerator();
|
||||
|
||||
var parsed = new CommandLineParser();
|
||||
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
var arg = enumerator.Current;
|
||||
|
||||
if (arg == "--configuration")
|
||||
{
|
||||
if (!enumerator.MoveNext())
|
||||
throw new InvalidOperationException("Missing args for --configuration");
|
||||
|
||||
parsed.Configuration = enumerator.Current;
|
||||
}
|
||||
|
||||
if (arg == "--root-path")
|
||||
{
|
||||
if(!enumerator.MoveNext())
|
||||
throw new InvalidOperationException("Missing args for --root-path");
|
||||
|
||||
parsed.RootPath = enumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,11 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Nebula.SharedModels\Nebula.SharedModels.csproj" />
|
||||
<ProjectReference Include="..\Nebula.Shared\Nebula.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -2,24 +2,36 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Nebula.Shared;
|
||||
using Nebula.SharedModels;
|
||||
|
||||
namespace Nebula.Packager;
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Pack("","Release");
|
||||
var parsedArgs = CommandLineParser.Parse(args);
|
||||
|
||||
Pack(parsedArgs.RootPath, parsedArgs.Configuration);
|
||||
}
|
||||
|
||||
private static void Pack(string rootPath,string configuration)
|
||||
private static string ShowEmptyOrValue(string? value)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(value)) return "<empty>";
|
||||
return value;
|
||||
}
|
||||
|
||||
private static void Pack(string rootPath, string configuration)
|
||||
{
|
||||
Console.WriteLine($"Packaging with arguments: RootPath {ShowEmptyOrValue(rootPath)} and Configuration {configuration}");
|
||||
|
||||
var processInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "dotnet",
|
||||
ArgumentList =
|
||||
{
|
||||
"publish",
|
||||
Path.Combine(rootPath,"Nebula.Launcher", "Nebula.Launcher.csproj"),
|
||||
Path.Combine(rootPath, "Nebula.Launcher", "Nebula.Launcher.csproj"),
|
||||
"-c", configuration,
|
||||
}
|
||||
};
|
||||
@@ -57,18 +69,14 @@ public static class Program
|
||||
entries.Add(new LauncherManifestEntry(hashStr, fileNameCut));
|
||||
Console.WriteLine($"Added {hashStr} file name {fileNameCut}");
|
||||
}
|
||||
|
||||
var manifestRuntimeInfo = new LauncherRuntimeInfo(
|
||||
CurrentConVar.DotnetVersion.DefaultValue!,
|
||||
CurrentConVar.DotnetUrl.DefaultValue!
|
||||
);
|
||||
|
||||
using var manifest = File.CreateText(Path.Combine(destinationDirectory, "manifest.json"));
|
||||
manifest.AutoFlush = true;
|
||||
manifest.Write(JsonSerializer.Serialize(new LauncherManifest(entries)));
|
||||
manifest.Write(JsonSerializer.Serialize(new LauncherManifest(entries, manifestRuntimeInfo)));
|
||||
}
|
||||
}
|
||||
|
||||
public record struct LauncherManifest(
|
||||
[property: JsonPropertyName("entries")] HashSet<LauncherManifestEntry> Entries
|
||||
);
|
||||
|
||||
public record struct LauncherManifestEntry(
|
||||
[property: JsonPropertyName("hash")] string Hash,
|
||||
[property: JsonPropertyName("path")] string Path
|
||||
);
|
||||
@@ -16,6 +16,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Nebula.SharedModels\Nebula.SharedModels.csproj" />
|
||||
<ProjectReference Include="..\Nebula.SourceGenerators\Nebula.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="..\Robust.LoaderApi\Robust.LoaderApi\Robust.LoaderApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -81,7 +81,7 @@ public partial class ContentService
|
||||
|
||||
var loadingHandler = loadingFactory.CreateLoadingContext(new FileLoadingFormater());
|
||||
|
||||
var response = await _http.GetAsync(info.DownloadUri, cancellationToken);
|
||||
var response = await _http.GetAsync(info.DownloadUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
loadingHandler.SetLoadingMessage("Downloading zip content");
|
||||
|
||||
8
Nebula.SharedModels/LauncherManifest.cs
Normal file
8
Nebula.SharedModels/LauncherManifest.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Nebula.SharedModels;
|
||||
|
||||
public record struct LauncherManifest(
|
||||
[property: JsonPropertyName("entries")] HashSet<LauncherManifestEntry> Entries,
|
||||
[property: JsonPropertyName("runtime_info")] LauncherRuntimeInfo RuntimeInfo
|
||||
);
|
||||
8
Nebula.SharedModels/LauncherManifestEntry.cs
Normal file
8
Nebula.SharedModels/LauncherManifestEntry.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Nebula.SharedModels;
|
||||
|
||||
public record struct LauncherManifestEntry(
|
||||
[property: JsonPropertyName("hash")] string Hash,
|
||||
[property: JsonPropertyName("path")] string Path
|
||||
);
|
||||
7
Nebula.SharedModels/LauncherRuntimeInfo.cs
Normal file
7
Nebula.SharedModels/LauncherRuntimeInfo.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Nebula.SharedModels;
|
||||
|
||||
public record struct LauncherRuntimeInfo(
|
||||
[property: JsonPropertyName("version")] string RuntimeVersion,
|
||||
[property: JsonPropertyName("runtimes")] Dictionary<string, string> DotnetRuntimes);
|
||||
9
Nebula.SharedModels/Nebula.SharedModels.csproj
Normal file
9
Nebula.SharedModels/Nebula.SharedModels.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -7,7 +7,8 @@ using System.Net.Http;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Nebula.UpdateResolver.Configuration;
|
||||
using Nebula.SharedModels;
|
||||
using Nebula.UpdateResolver.Rest;
|
||||
|
||||
namespace Nebula.UpdateResolver;
|
||||
|
||||
@@ -15,19 +16,21 @@ public static class DotnetStandalone
|
||||
{
|
||||
private static readonly HttpClient HttpClient = new();
|
||||
|
||||
private static readonly string FullPath =
|
||||
Path.Join(MainWindow.RootPath, $"dotnet.{ConfigurationStandalone.GetConfigValue(UpdateConVars.DotnetVersion)}",
|
||||
DotnetUrlHelper.GetRuntimeIdentifier());
|
||||
|
||||
private static readonly string ExecutePath = Path.Join(FullPath, "dotnet" + DotnetUrlHelper.GetExtension());
|
||||
|
||||
public static async Task<Process?> Run(string dllPath)
|
||||
private static string GetExecutePath(LauncherRuntimeInfo runtimeInfo)
|
||||
{
|
||||
await EnsureDotnet();
|
||||
return Path.Join(MainWindow.RootPath,
|
||||
$"dotnet.{runtimeInfo.RuntimeVersion}",
|
||||
DotnetUrlHelper.GetRuntimeIdentifier(),
|
||||
$"dotnet{DotnetUrlHelper.GetExtension()}");
|
||||
}
|
||||
|
||||
public static async Task<Process?> Run(LauncherRuntimeInfo runtimeInfo, string dllPath)
|
||||
{
|
||||
await EnsureDotnet(runtimeInfo);
|
||||
|
||||
return Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = ExecutePath,
|
||||
FileName = GetExecutePath(runtimeInfo),
|
||||
Arguments = dllPath,
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
@@ -37,35 +40,38 @@ public static class DotnetStandalone
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task EnsureDotnet()
|
||||
private static async Task EnsureDotnet(LauncherRuntimeInfo runtimeInfo)
|
||||
{
|
||||
if (!Directory.Exists(FullPath))
|
||||
await Download();
|
||||
if (!Directory.Exists(GetExecutePath(runtimeInfo)))
|
||||
await Download(runtimeInfo);
|
||||
}
|
||||
|
||||
private static async Task Download()
|
||||
private static async Task Download(LauncherRuntimeInfo runtimeInfo)
|
||||
{
|
||||
LogStandalone.Log($"Downloading dotnet {DotnetUrlHelper.GetRuntimeIdentifier()}...");
|
||||
|
||||
var url = DotnetUrlHelper.GetCurrentPlatformDotnetUrl(
|
||||
ConfigurationStandalone.GetConfigValue(UpdateConVars.DotnetUrl)!
|
||||
);
|
||||
var fullPath = GetExecutePath(runtimeInfo);
|
||||
|
||||
using var response = await HttpClient.GetAsync(url);
|
||||
var url = DotnetUrlHelper.GetCurrentPlatformDotnetUrl(runtimeInfo.DotnetRuntimes);
|
||||
|
||||
using var response = await HttpClient.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);
|
||||
response.EnsureSuccessStatusCode();
|
||||
await using var stream = await response.Content.ReadAsStreamAsync();
|
||||
var stream = await response.Content.ReadAsStreamAsync();
|
||||
await using var tempStream = new MemoryStream();
|
||||
stream.CopyTo(tempStream,"dotnet", response.Content.Headers.ContentLength ?? 0);
|
||||
await stream.DisposeAsync();
|
||||
|
||||
Directory.CreateDirectory(FullPath);
|
||||
Directory.CreateDirectory(fullPath);
|
||||
|
||||
if (url.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
using var zipArchive = new ZipArchive(stream);
|
||||
zipArchive.ExtractToDirectory(FullPath, true);
|
||||
await using var zipArchive = new ZipArchive(tempStream);
|
||||
await zipArchive.ExtractToDirectoryAsync(fullPath, true);
|
||||
}
|
||||
else if (url.EndsWith(".tar.gz", StringComparison.OrdinalIgnoreCase)
|
||||
|| url.EndsWith(".tgz", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
TarUtils.ExtractTarGz(stream, FullPath);
|
||||
TarUtils.ExtractTarGz(tempStream, fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -80,10 +86,8 @@ public static class DotnetUrlHelper
|
||||
{
|
||||
public static string GetExtension()
|
||||
{
|
||||
if (OperatingSystem.IsWindows()) return ".exe";
|
||||
return "";
|
||||
return OperatingSystem.IsWindows() ? ".exe" : string.Empty;
|
||||
}
|
||||
|
||||
public static string GetCurrentPlatformDotnetUrl(Dictionary<string, string> dotnetUrl)
|
||||
{
|
||||
var rid = GetRuntimeIdentifier();
|
||||
@@ -96,10 +100,38 @@ public static class DotnetUrlHelper
|
||||
public static string GetRuntimeIdentifier()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
return Environment.Is64BitProcess ? "win-x64" : "win-x86";
|
||||
{
|
||||
return RuntimeInformation.ProcessArchitecture switch
|
||||
{
|
||||
Architecture.X64 => "win-x64",
|
||||
Architecture.X86 => "win-x86",
|
||||
Architecture.Arm64 => "win-arm64",
|
||||
_ => throw new PlatformNotSupportedException($"Unsupported Windows architecture: {RuntimeInformation.ProcessArchitecture}")
|
||||
};
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return "linux-x64";
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
return RuntimeInformation.ProcessArchitecture switch
|
||||
{
|
||||
Architecture.X64 => "linux-x64",
|
||||
Architecture.X86 => "linux-x86",
|
||||
Architecture.Arm => "linux-arm",
|
||||
Architecture.Arm64 => "linux-arm64",
|
||||
_ => throw new PlatformNotSupportedException($"Unsupported Linux architecture: {RuntimeInformation.ProcessArchitecture}")
|
||||
};
|
||||
}
|
||||
|
||||
throw new PlatformNotSupportedException("Unsupported operating system");
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
return RuntimeInformation.ProcessArchitecture switch
|
||||
{
|
||||
Architecture.X64 => "osx-x64",
|
||||
Architecture.Arm64 => "osx-arm64",
|
||||
_ => throw new PlatformNotSupportedException($"Unsupported macOS architecture: {RuntimeInformation.ProcessArchitecture}")
|
||||
};
|
||||
}
|
||||
|
||||
throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}");
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Nebula.UpdateResolver;
|
||||
|
||||
public record struct LauncherManifest(
|
||||
[property: JsonPropertyName("entries")] HashSet<LauncherManifestEntry> Entries
|
||||
);
|
||||
|
||||
public record struct LauncherManifestEntry(
|
||||
[property: JsonPropertyName("hash")] string Hash,
|
||||
[property: JsonPropertyName("path")] string Path
|
||||
);
|
||||
@@ -3,10 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Nebula.SharedModels;
|
||||
using Nebula.UpdateResolver.Configuration;
|
||||
using Nebula.UpdateResolver.Rest;
|
||||
|
||||
@@ -19,7 +19,8 @@ public partial class MainWindow : Window
|
||||
|
||||
private readonly HttpClient _httpClient = new HttpClient();
|
||||
public readonly FileApi FileApi = new FileApi(Path.Join(RootPath,"app"));
|
||||
private string LogStr = "";
|
||||
private string _logStr = "";
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -34,7 +35,7 @@ public partial class MainWindow : Window
|
||||
var messageOut =
|
||||
$"[{DateTime.Now.ToUniversalTime():yyyy-MM-dd HH:mm:ss}]: {message} {PercentLabel.Content}";
|
||||
Console.WriteLine(messageOut);
|
||||
LogStr += messageOut + "\n";
|
||||
_logStr += messageOut + "\n";
|
||||
};
|
||||
LogStandalone.Log("Starting up");
|
||||
if (!Design.IsDesignMode)
|
||||
@@ -47,7 +48,11 @@ public partial class MainWindow : Window
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = await EnsureFiles();
|
||||
var manifest = await RestStandalone.GetAsync<LauncherManifest>(
|
||||
new Uri(ConfigurationStandalone.GetConfigValue(UpdateConVars.UpdateCacheUrl)! + "/manifest.json"), CancellationToken.None);
|
||||
|
||||
var info = EnsureFiles(FilterEntries(manifest.Entries));
|
||||
|
||||
LogStandalone.Log("Downloading files...");
|
||||
|
||||
foreach (var file in info.ToDelete)
|
||||
@@ -57,7 +62,7 @@ public partial class MainWindow : Window
|
||||
}
|
||||
|
||||
var loadedManifest = info.FilesExist;
|
||||
Save(loadedManifest);
|
||||
Save(loadedManifest, manifest.RuntimeInfo);
|
||||
|
||||
var count = info.ToDownload.Count;
|
||||
var resolved = 0;
|
||||
@@ -75,18 +80,18 @@ public partial class MainWindow : Window
|
||||
LogStandalone.Log("Saving " + file.Path, (int)(resolved / (float)count * 100f));
|
||||
|
||||
loadedManifest.Add(file);
|
||||
Save(loadedManifest);
|
||||
Save(loadedManifest, manifest.RuntimeInfo);
|
||||
}
|
||||
|
||||
LogStandalone.Log("Download finished. Running launcher...");
|
||||
|
||||
await DotnetStandalone.Run(Path.Join(FileApi.RootPath, "Nebula.Launcher.dll"));
|
||||
await DotnetStandalone.Run(manifest.RuntimeInfo, Path.Join(FileApi.RootPath, "Nebula.Launcher.dll"));
|
||||
}
|
||||
catch(HttpRequestException e){
|
||||
LogStandalone.LogError(e);
|
||||
LogStandalone.Log("Network connection error...");
|
||||
var logPath = Path.Join(RootPath,"updateResloverError.txt");
|
||||
await File.WriteAllTextAsync(logPath, LogStr);
|
||||
await File.WriteAllTextAsync(logPath, _logStr);
|
||||
Process.Start(new ProcessStartInfo(){
|
||||
FileName = "notepad",
|
||||
Arguments = logPath
|
||||
@@ -96,7 +101,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
LogStandalone.LogError(e);
|
||||
var logPath = Path.Join(RootPath,"updateResloverError.txt");
|
||||
await File.WriteAllTextAsync(logPath, LogStr);
|
||||
await File.WriteAllTextAsync(logPath, _logStr);
|
||||
Process.Start(new ProcessStartInfo(){
|
||||
FileName = "notepad",
|
||||
Arguments = logPath
|
||||
@@ -108,11 +113,9 @@ public partial class MainWindow : Window
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private async Task<ManifestEnsureInfo> EnsureFiles()
|
||||
private ManifestEnsureInfo EnsureFiles(HashSet<LauncherManifestEntry> entries)
|
||||
{
|
||||
LogStandalone.Log("Ensuring launcher manifest...");
|
||||
var manifest = await RestStandalone.GetAsync<LauncherManifest>(
|
||||
new Uri(ConfigurationStandalone.GetConfigValue(UpdateConVars.UpdateCacheUrl)! + "/manifest.json"), CancellationToken.None);
|
||||
|
||||
var toDownload = new HashSet<LauncherManifestEntry>();
|
||||
var toDelete = new HashSet<LauncherManifestEntry>();
|
||||
@@ -124,13 +127,13 @@ public partial class MainWindow : Window
|
||||
LogStandalone.Log("Delta manifest loaded!");
|
||||
foreach (var file in currentManifest.Entries)
|
||||
{
|
||||
if (!manifest.Entries.Contains(file))
|
||||
if (!entries.Contains(file))
|
||||
toDelete.Add(EnsurePath(file));
|
||||
else
|
||||
filesExist.Add(EnsurePath(file));
|
||||
}
|
||||
|
||||
foreach (var file in manifest.Entries)
|
||||
foreach (var file in entries)
|
||||
{
|
||||
if(!currentManifest.Entries.Contains(file))
|
||||
toDownload.Add(EnsurePath(file));
|
||||
@@ -138,18 +141,37 @@ public partial class MainWindow : Window
|
||||
}
|
||||
else
|
||||
{
|
||||
toDownload = manifest.Entries;
|
||||
toDownload = entries;
|
||||
}
|
||||
|
||||
LogStandalone.Log("Saving launcher manifest...");
|
||||
|
||||
return new ManifestEnsureInfo(toDownload, toDelete, filesExist);
|
||||
}
|
||||
|
||||
|
||||
private void Save(HashSet<LauncherManifestEntry> entries)
|
||||
private HashSet<LauncherManifestEntry> FilterEntries(IEnumerable<LauncherManifestEntry> entries)
|
||||
{
|
||||
ConfigurationStandalone.SetConfigValue(UpdateConVars.CurrentLauncherManifest, new LauncherManifest(entries));
|
||||
var filtered = new HashSet<LauncherManifestEntry>();
|
||||
var runtimeIdentifier = DotnetUrlHelper.GetRuntimeIdentifier();
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var splited = entry.Path.Split("/");
|
||||
|
||||
if(splited.Length < 2 ||
|
||||
splited[0] != "runtimes" ||
|
||||
splited[1] == runtimeIdentifier)
|
||||
{
|
||||
filtered.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
private void Save(HashSet<LauncherManifestEntry> entries, LauncherRuntimeInfo info)
|
||||
{
|
||||
ConfigurationStandalone.SetConfigValue(UpdateConVars.CurrentLauncherManifest, new LauncherManifest(entries, info));
|
||||
}
|
||||
|
||||
private LauncherManifestEntry EnsurePath(LauncherManifestEntry entry)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Nebula.SharedModels;
|
||||
|
||||
namespace Nebula.UpdateResolver;
|
||||
|
||||
|
||||
@@ -26,4 +26,8 @@
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Nebula.SharedModels\Nebula.SharedModels.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,31 +8,25 @@ namespace Nebula.UpdateResolver.Rest;
|
||||
public static class Helper
|
||||
{
|
||||
public static readonly JsonSerializerOptions JsonWebOptions = new(JsonSerializerDefaults.Web);
|
||||
public static void SafeOpenBrowser(string uri)
|
||||
{
|
||||
if (!Uri.TryCreate(uri, UriKind.Absolute, out var parsedUri))
|
||||
{
|
||||
Console.WriteLine("Unable to parse URI in server-provided link: {Link}", uri);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsedUri.Scheme is not ("http" or "https"))
|
||||
{
|
||||
Console.WriteLine("Refusing to open server-provided link {Link}, only http/https are allowed", parsedUri);
|
||||
return;
|
||||
}
|
||||
|
||||
OpenBrowser(parsedUri.ToString());
|
||||
}
|
||||
public static void OpenBrowser(string url)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
||||
}
|
||||
|
||||
public static async Task<T> AsJson<T>(this HttpContent content) where T : notnull
|
||||
{
|
||||
var str = await content.ReadAsStringAsync();
|
||||
return JsonSerializer.Deserialize<T>(str, JsonWebOptions) ??
|
||||
throw new JsonException("AsJson: did not expect null response");
|
||||
}
|
||||
|
||||
public static void CopyTo(this Stream input, Stream output, string fileName, long totalLength)
|
||||
{
|
||||
const int bufferSize = 81920;
|
||||
var buffer = new byte[bufferSize];
|
||||
|
||||
long totalRead = 0;
|
||||
int bytesRead;
|
||||
while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
output.Write(buffer, 0, bytesRead);
|
||||
totalRead += bytesRead;
|
||||
LogStandalone.Log($"Saving {fileName}", (int)(((float)totalLength / totalRead) * 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Nebula.SharedModels;
|
||||
using Nebula.UpdateResolver.Configuration;
|
||||
|
||||
namespace Nebula.UpdateResolver;
|
||||
@@ -9,13 +9,4 @@ public static class UpdateConVars
|
||||
ConVarBuilder.Build<string>("update.url","https://durenko.tatar/nebula/manifest/");
|
||||
public static readonly ConVar<LauncherManifest> CurrentLauncherManifest =
|
||||
ConVarBuilder.Build<LauncherManifest>("update.manifest");
|
||||
|
||||
public static readonly ConVar<Dictionary<string,string>> DotnetUrl = ConVarBuilder.Build<Dictionary<string,string>>("dotnet.url",
|
||||
new(){
|
||||
{"win-x64", "https://builds.dotnet.microsoft.com/dotnet/Runtime/10.0.2/dotnet-runtime-10.0.2-win-x64.zip"},
|
||||
{"win-x86", "https://builds.dotnet.microsoft.com/dotnet/Runtime/10.0.2/dotnet-runtime-10.0.2-win-x86.zip"},
|
||||
{"linux-x64", "https://builds.dotnet.microsoft.com/dotnet/Runtime/10.0.2/dotnet-runtime-10.0.2-linux-x64.tar.gz"}
|
||||
});
|
||||
|
||||
public static readonly ConVar<string> DotnetVersion = ConVarBuilder.Build<string>("dotnet.version", "10.0.2");
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArchiving_002EUtils_002EWindows_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F27e9f12ad1e4318b9b02849ec3e6a502fa3ee761c4f0522ba756ab30cde1c_003FArchiving_002EUtils_002EWindows_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArray_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F24f5857a073841e189d805de9660178ef49910_003F45_003F049a0c03_003FArray_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAssembly_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F501151723a8d43558c75acbd334f26322066fa4b1c82b1297291314bf92ff_003FAssembly_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAuthenticationHeaderValue_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F88b338246f59cffdb6f3dc3d8dbcfc169599dc71d6f44a8f2732983db7f73a_003FAuthenticationHeaderValue_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAvaloniaList_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F3cc366334cc52275393f9def48cfcbccc8382175579fbd4f75b8c0e4bf33_003FAvaloniaList_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
@@ -29,6 +30,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFuture_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fb3575a2f41d7c2dbfaa36e866b8a361e11dd7223ff82bc574c1d5d4b7522f735_003FFuture_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpBaseStream_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F5c9ea82983a677ae263ed0c49dd93a5e32866ad7ae97beea733f6df197e995_003FHttpBaseStream_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpClient_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc439425da351c75ac7d966a1cc8324b51a9c471865af79d2f2f3fcb65e392_003FHttpClient_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpClient_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fd1d7280b53be4f32b5e9b2587f54915348ec89107b99282d2748ac94b8c1_003FHttpClient_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpCompletionOption_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffcc079c54e9940c5ac59f0141dda9ad01b4928_003F28_003Fe60e6194_003FHttpCompletionOption_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpContent_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F9657cc383c70851dc2bdcf91eff27f21196844abfe552fc9c3243ff36974cd_003FHttpContent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpListener_002EWindows_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Ffb21cfde6c1ffa9b6be622d15d56f666ad94ada7dd7d81451418d807b98f2_003FHttpListener_002EWindows_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
@@ -40,6 +42,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpResponseMessage_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F4cfeb8b377bc81e1fbb5f7d7a02492cb6ac23e88c8c9d7155944f0716f3d4b_003FHttpResponseMessage_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIDispatcherImpl_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F22d92db124764b1ab49745245c66f01b1e1a00_003F0f_003F01061787_003FIDispatcherImpl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIDisposable_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa6b7f037ba7b44df80b8d3aa7e58eeb2e8e938_003F98_003Fd1b23281_003FIDisposable_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIEnumerable_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F24f5857a073841e189d805de9660178ef49910_003Fbc_003F64378026_003FIEnumerable_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIGeometryContext_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F22d92db124764b1ab49745245c66f01b1e1a00_003F_005F2c742_003FIGeometryContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AImage_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F2b95745d8f2ddf7b8ad6130e01c5b2782e253ff11247a9aeefcef47277b1ab_003FImage_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIndex_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F2a1a813823579c69832f1304f97761e7be433bd6aa928f351d138050b56a38_003FIndex_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<Project Path="Nebula.Launcher\Nebula.Launcher.csproj" Type="Classic C#" />
|
||||
<Project Path="Nebula.Packager\Nebula.Packager.csproj" Type="Classic C#" />
|
||||
<Project Path="Nebula.Runner\Nebula.Runner.csproj" Type="Classic C#" />
|
||||
<Project Path="Nebula.SharedModels\Nebula.SharedModels.csproj" Type="Classic C#" />
|
||||
<Project Path="Nebula.Shared\Nebula.Shared.csproj" Type="Classic C#" />
|
||||
<Project Path="Nebula.SourceGenerators\Nebula.SourceGenerators.csproj" Type="Classic C#" />
|
||||
<Project Path="Nebula.UnitTest\Nebula.UnitTest.csproj" Type="Classic C#" />
|
||||
|
||||
Reference in New Issue
Block a user