Skip to content

Commit

Permalink
Added support for unix file paths
Browse files Browse the repository at this point in the history
Updated workflow to also build smaller portable executables
  • Loading branch information
LennardF1989 committed Feb 14, 2024
1 parent cc4e10b commit d74b5f0
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 33 deletions.
43 changes: 33 additions & 10 deletions .github/workflows/patcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,47 @@ jobs:
run: |
export DOTNET_NOLOGO=true
export DOTNET_CLI_TELEMETRY_OPTOUT=true
dotnet publish patcher/HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r win-x64 -c Release -p:PublishTrimmed=True -p:PublishSingleFile=True --self-contained -p DebugType=none -p:EnableWindowsTargeting=True --nologo -o patcher/Publish/Windows-x64
dotnet publish patcher/HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r linux-x64 -c Release -p:PublishTrimmed=True -p:PublishSingleFile=True --self-contained -p DebugType=none --nologo -o patcher/Publish/Linux-x64
dotnet publish patcher/HitmanPatcher.UI/HitmanPatcher.UI.csproj -r win-x64 -c Release -p:PublishSingleFile=True --self-contained -p DebugType=none -p:EnableWindowsTargeting=True --nologo -o patcher/Publish/Windows-x64
cd patcher
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r win-x64 -c Release -p:PublishSingleFile=True --no-self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-Portable
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r win-x64 -c Release -p:PublishTrimmed=True -p:PublishSingleFile=True --self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-x64
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r linux-x64 -c Release -p:PublishSingleFile=True --no-self-contained -p DebugType=none -p:IsLinux=true -o Publish/Linux-Portable
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r linux-x64 -c Release -p:PublishTrimmed=True -p:PublishSingleFile=True --self-contained -p DebugType=none -p:IsLinux=true -o Publish/Linux-x64
dotnet publish HitmanPatcher.UI/HitmanPatcher.UI.csproj -r win-x64 -c Release -p:PublishSingleFile=True --no-self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-Portable
dotnet publish HitmanPatcher.UI/HitmanPatcher.UI.csproj -r win-x64 -c Release -p:PublishSingleFile=True --self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-x64
- name: Upload patcher-windows-cli
- name: Upload patcher-cli-windows-portable
uses: actions/upload-artifact@v4
with:
name: patcher-windows-cli
name: patcher-cli-windows-portable
path: patcher/Publish/Windows-Portable/PeacockPatcher.CLI.exe

- name: Upload patcher-cli-windows
uses: actions/upload-artifact@v4
with:
name: patcher-cli-windows
path: patcher/Publish/Windows-x64/PeacockPatcher.CLI.exe

- name: Upload patcher-windows-ui
- name: Upload patcher-cli-linux-portable
uses: actions/upload-artifact@v4
with:
name: patcher-windows-ui
path: patcher/Publish/Windows-x64/PeacockPatcher.UI.exe
name: patcher-cli-linux-portable
path: patcher/Publish/Linux-Portable/PeacockPatcher.CLI.exe

- name: Upload patcher-linux-cli
- name: Upload patcher-cli-linux
uses: actions/upload-artifact@v4
with:
name: patcher-linux-cli
name: patcher-cli-linux
path: patcher/Publish/Linux-x64/PeacockPatcher.CLI.exe

- name: Upload patcher-ui-windows-portable
uses: actions/upload-artifact@v4
with:
name: patcher-ui-windows-portable
path: patcher/Publish/Windows-Portable/PeacockPatcher.UI.exe

- name: Upload patcher-ui-windows
uses: actions/upload-artifact@v4
with:
name: patcher-ui-windows
path: patcher/Publish/Windows-x64/PeacockPatcher.UI.exe

1 change: 1 addition & 0 deletions patcher/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vs
bin
obj
/Publish
/HitmanPatcher.sln.DotSettings.user
/.idea/.idea.HitmanPatcher/.idea/riderMarkupCache.xml
*.suo
Expand Down
4 changes: 3 additions & 1 deletion patcher/HitmanPatcher.CLI/HitmanPatcher.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<RootNamespace>HitmanPatcher</RootNamespace>
<AssemblyName>PeacockPatcher.CLI</AssemblyName>

<Title>Peacock Patcher</Title>
<Description>Peacock's HITMAN™ World of Assassination trilogy game patcher.</Description>
<Company>The Peacock Project</Company>
Expand All @@ -18,6 +18,8 @@
<ApplicationIcon>patcher.ico</ApplicationIcon>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<FileVersion>8.0.0.0</FileVersion>

<DefineConstants Condition="'$(IsLinux)' == 'true'">$(DefineConstants);LINUX</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions patcher/HitmanPatcher.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private static void Main(string[] args)
settings.SaveToFile();

Console.WriteLine("Settings:");
Console.WriteLine($"- File = {Path.GetFullPath(Settings.GetSavePath())}");
Console.WriteLine($"- CustomConfigDomain = {settings.patchOptions.CustomConfigDomain}");
Console.WriteLine($"- UseHttp = {settings.patchOptions.UseHttp}");
Console.WriteLine($"- DisableForceDynamicResources = {settings.patchOptions.DisableForceOfflineOnFailedDynamicResources}");
Expand Down
8 changes: 4 additions & 4 deletions patcher/HitmanPatcher.Core/Compositions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if WINDOWS
#if !LINUX
using System.Security.Principal;
#endif

Expand All @@ -16,12 +16,12 @@ public static void Initialize()

private static bool CheckForAdmin()
{
#if WINDOWS
#if LINUX
return false;
#else
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
#else
return false;
#endif
}
}
Expand Down
3 changes: 3 additions & 0 deletions patcher/HitmanPatcher.Core/HitmanPatcher.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@

<RootNamespace>HitmanPatcher</RootNamespace>
<AssemblyName>PeacockPatcher.Core</AssemblyName>

<DefineConstants Condition=" '$(IsLinux)' == 'true' ">$(DefineConstants);LINUX</DefineConstants>
<NoWarn Condition=" '$(IsLinux)' != 'true' ">CA1416</NoWarn>
</PropertyGroup>
</Project>
34 changes: 16 additions & 18 deletions patcher/HitmanPatcher.Core/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;

namespace HitmanPatcher
{
public class Settings
Expand Down Expand Up @@ -30,27 +26,29 @@ public Settings()
trayDomains = new List<string>();
}

private static string GetSavePath()
public static string GetSavePath()
{
if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PeacockProject"))
#if LINUX
return "peacock_patcher.conf";
#else
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string folder = Path.Combine(appData, "PeacockProject");

if (!Directory.Exists(folder))
{
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PeacockProject");
Directory.CreateDirectory(folder);
}

string appData = Environment.GetFolderPath(Environment
.SpecialFolder
.ApplicationData);

string folder = $@"{appData}\PeacockProject\";
string config1 = folder + "peacock_patcher.conf";
string config2 = folder + "peacock_patcher2.conf";
string config1 = Path.Combine(folder, "peacock_patcher.conf");
string config2 = Path.Combine(folder, "peacock_patcher2.conf");

if (File.Exists(config1))
{
File.Delete(config1);
}

return config2;
#endif
}

public void SaveToFile()
Expand All @@ -59,7 +57,7 @@ public void SaveToFile()
lines.Add(string.Format("CustomConfigDomain={0}", patchOptions.CustomConfigDomain));
lines.Add(string.Format("UseHttp={0}", patchOptions.UseHttp));
lines.Add(string.Format("DisableForceDynamicResources={0}", patchOptions.DisableForceOfflineOnFailedDynamicResources));
lines.Add(string.Format("DarkModeEnabled={0}", darkModeEnabled));
lines.Add(string.Format("DarkModeEnabled={0}", darkModeEnabled));
lines.Add(string.Format("startInTray={0}", startInTray));
lines.Add(string.Format("minToTray={0}", minimizeToTray));

Expand Down Expand Up @@ -100,9 +98,9 @@ public static Settings GetFromFile()
case "DisableForceDynamicResources":
result.patchOptions.DisableForceOfflineOnFailedDynamicResources = bool.Parse(linecontents[1]);
break;
case "DarkModeEnabled":
result.darkModeEnabled = bool.Parse(linecontents[1]);
break;
case "DarkModeEnabled":
result.darkModeEnabled = bool.Parse(linecontents[1]);
break;
case "startInTray":
result.startInTray = bool.Parse(linecontents[1]);
break;
Expand Down
2 changes: 2 additions & 0 deletions patcher/HitmanPatcher.UI/HitmanPatcher.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<ApplicationIcon>patcher.ico</ApplicationIcon>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<FileVersion>8.0.0.0</FileVersion>

<DefineConstants Condition="'$(IsLinux)' == 'true'">$(DefineConstants);LINUX</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 14 additions & 0 deletions patcher/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off
rem Windows - CLI
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r win-x64 -c Release -p:PublishSingleFile=True --no-self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-Portable
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r win-x64 -c Release -p:PublishTrimmed=True -p:PublishSingleFile=True --self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-x64

rem Linux - CLI
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r linux-x64 -c Release -p:PublishSingleFile=True --no-self-contained -p DebugType=none -p:IsLinux=true -o Publish/Linux-Portable
dotnet publish HitmanPatcher.CLI/HitmanPatcher.CLI.csproj -r linux-x64 -c Release -p:PublishTrimmed=True -p:PublishSingleFile=True --self-contained -p DebugType=none -p:IsLinux=true -o Publish/Linux-x64

rem Windows - UI
dotnet publish HitmanPatcher.UI/HitmanPatcher.UI.csproj -r win-x64 -c Release -p:PublishSingleFile=True --no-self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-Portable
dotnet publish HitmanPatcher.UI/HitmanPatcher.UI.csproj -r win-x64 -c Release -p:PublishSingleFile=True --self-contained -p DebugType=none -p:EnableWindowsTargeting=True -o Publish/Windows-x64

pause

0 comments on commit d74b5f0

Please sign in to comment.