0
0
mirror of https://github.com/sp-tarkov/patcher.git synced 2025-02-13 01:50:47 -05:00

Merge pull request 'net8' (#16) from net8 into main

Reviewed-on: waffle.lord/Patcher#16
This commit is contained in:
IsWaffle 2024-03-22 18:38:32 +00:00
commit 9458713269
11 changed files with 63 additions and 32 deletions

View File

@ -5,6 +5,7 @@
<map> <map>
<entry key="PatchClient/Views/MainWindow.axaml" value="PatchClient/PatchClient.csproj" /> <entry key="PatchClient/Views/MainWindow.axaml" value="PatchClient/PatchClient.csproj" />
<entry key="PatchGenerator/Views/MainWindow.axaml" value="PatchGenerator/PatchGenerator.csproj" /> <entry key="PatchGenerator/Views/MainWindow.axaml" value="PatchGenerator/PatchGenerator.csproj" />
<entry key="PatchGenerator/Views/OptionsView.axaml" value="PatchGenerator/PatchGenerator.csproj" />
</map> </map>
</option> </option>
</component> </component>

View File

@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyVersion>2.10.2</AssemblyVersion> <AssemblyVersion>2.12.0</AssemblyVersion>
<FileVersion>2.10.2</FileVersion> <FileVersion>2.12.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<AvaloniaResource Include="Assets\**" /> <AvaloniaResource Include="Assets\**" />

View File

@ -11,9 +11,6 @@ namespace PatchClient.Views
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
} }
private void InitializeComponent() private void InitializeComponent()

View File

@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyVersion>2.10.2</AssemblyVersion> <AssemblyVersion>2.12.0</AssemblyVersion>
<FileVersion>2.10.2</FileVersion> <FileVersion>2.12.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -27,8 +27,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\7za.exe" /> <None Remove="Resources\7z.dll" />
<EmbeddedResource Include="Resources\PatchClient.exe" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.11" /> <PackageReference Include="Avalonia" Version="0.10.11" />
@ -42,4 +41,7 @@
<DependentUpon>%(Filename)</DependentUpon> <DependentUpon>%(Filename)</DependentUpon>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\PatchClient.exe" />
</ItemGroup>
</Project> </Project>

Binary file not shown.

View File

@ -16,6 +16,7 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
using PatcherUtils.Model;
namespace PatchGenerator.ViewModels namespace PatchGenerator.ViewModels
{ {
@ -140,12 +141,19 @@ namespace PatchGenerator.ViewModels
System.Threading.Thread.Sleep(2000); System.Threading.Thread.Sleep(2000);
PatchItemCollection.Add(new PatchItem("Kicking off 7zip ...")); PatchItemCollection.Add(new PatchItem("Zipping patcher ..."));
LazyOperations.StartZipProcess(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.zip".FromCwd()); ProgressMessage = "Zipping patcher";
IndeterminateProgress = false; IndeterminateProgress = false;
var progress = new Progress<int>(p =>
{
PatchPercent = p;
});
LazyOperations.CompressDirectory(generationInfo.PatchName.FromCwd(), $"{generationInfo.PatchName}.7z".FromCwd(), progress);
PatchItemCollection.Add(new PatchItem("Done")); PatchItemCollection.Add(new PatchItem("Done"));
} }

View File

@ -11,9 +11,6 @@ namespace PatchGenerator.Views
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
} }
private void InitializeComponent() private void InitializeComponent()

View File

@ -1,7 +1,9 @@
using PatcherUtils.Model; using System;
using System.Diagnostics; using PatcherUtils.Model;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using Aki.Common.Utils;
using SevenZip;
namespace PatcherUtils namespace PatcherUtils
{ {
@ -18,12 +20,12 @@ namespace PatcherUtils
/// </summary> /// </summary>
public static string PatchFolder = "Aki_Patches"; public static string PatchFolder = "Aki_Patches";
private static string SevenZExe = "7za.exe"; private static string SevenZDll = "7z.dll";
/// <summary> /// <summary>
/// The path to the 7za.exe file in the <see cref="TempDir"/> /// The path to the 7za.exe file in the <see cref="TempDir"/>
/// </summary> /// </summary>
public static string SevenZExePath = $"{TempDir}\\{SevenZExe}"; public static string SevenZDllPath = $"{TempDir}\\{SevenZDll}";
private static string PatcherClient = "PatchClient.exe"; private static string PatcherClient = "PatchClient.exe";
/// <summary> /// <summary>
@ -79,9 +81,9 @@ namespace PatcherUtils
{ {
switch (resource) switch (resource)
{ {
case string a when a.EndsWith(SevenZExe): case string a when a.EndsWith(SevenZDll):
{ {
StreamResourceOut(assembly, resource, SevenZExePath); StreamResourceOut(assembly, resource, SevenZDllPath);
break; break;
} }
case string a when a.EndsWith(PatcherClient): case string a when a.EndsWith(PatcherClient):
@ -98,17 +100,34 @@ namespace PatcherUtils
} }
} }
public static void StartZipProcess(string SourcePath, string DestinationPath) public static void CompressDirectory(string SourceDirectoryPath, string DestinationFilePath, IProgress<int> progress)
{ {
ProcessStartInfo procInfo = new ProcessStartInfo() var outputFile = new FileInfo(DestinationFilePath);
SevenZipBase.SetLibraryPath(SevenZDllPath);
var compressor = new SevenZipCompressor()
{ {
FileName = SevenZExePath, ArchiveFormat = OutArchiveFormat.SevenZip,
Arguments = $"a -mm=LZMA {DestinationPath} {SourcePath}" CompressionMethod = CompressionMethod.Lzma2,
CompressionLevel = CompressionLevel.Normal
}; };
Process.Start(procInfo); compressor.Compressing += (_, args) =>
{
progress.Report(args.PercentDone);
};
PatchLogger.LogInfo($"Zip process started"); using var outputStream = outputFile.OpenWrite();
compressor.CompressDirectory(SourceDirectoryPath, outputStream);
outputFile.Refresh();
// failed to compress data
if (!outputFile.Exists || outputFile.Length == 0)
{
Logger.LogError("Failed to compress patcher");
}
} }
/// <summary> /// <summary>

View File

@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<AssemblyVersion>2.11.0</AssemblyVersion>
<FileVersion>2.11.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -9,6 +11,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\7z.dll" />
<EmbeddedResource Include="Resources\xdelta3.exe" /> <EmbeddedResource Include="Resources\xdelta3.exe" />
</ItemGroup> </ItemGroup>
@ -18,4 +21,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.1.23" />
</ItemGroup>
</Project> </Project>

Binary file not shown.