mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Include ASF's windows-only parts only in generic and windows builds (#2404)
* Include ASF's windows-only parts only in generic and windows builds * Apply Abry's note
This commit is contained in:
parent
1fda77a72d
commit
bb513921f1
7 changed files with 44 additions and 6 deletions
|
@ -29,7 +29,7 @@
|
|||
<PackageReference Include="System.Linq.Async" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net48'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net48' AND ('$(TargetGeneric)' == 'true' OR '$(TargetWindows)' == 'true')">
|
||||
<PackageReference Include="Microsoft.Win32.SystemEvents" />
|
||||
<PackageReference Include="System.IO.FileSystem.AccessControl" />
|
||||
<PackageReference Include="System.Security.Cryptography.ProtectedData" />
|
||||
|
|
|
@ -74,10 +74,12 @@ namespace ArchiSteamFarm.Core {
|
|||
}
|
||||
}
|
||||
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
internal static void OnTimeChanged(object? sender, EventArgs e) {
|
||||
lock (LockObject) {
|
||||
Timer.Change(TimeSpan.Zero, Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ namespace ArchiSteamFarm.Helpers {
|
|||
return null;
|
||||
}
|
||||
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
try {
|
||||
byte[] decryptedData = ProtectedData.Unprotect(
|
||||
Convert.FromBase64String(encryptedString),
|
||||
|
@ -206,6 +207,9 @@ namespace ArchiSteamFarm.Helpers {
|
|||
|
||||
return null;
|
||||
}
|
||||
#else
|
||||
throw new InvalidOperationException();
|
||||
#endif
|
||||
}
|
||||
|
||||
private static string? EncryptAES(string decryptedString) {
|
||||
|
@ -240,6 +244,7 @@ namespace ArchiSteamFarm.Helpers {
|
|||
return null;
|
||||
}
|
||||
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
try {
|
||||
byte[] encryptedData = ProtectedData.Protect(
|
||||
Encoding.UTF8.GetBytes(decryptedString),
|
||||
|
@ -253,6 +258,9 @@ namespace ArchiSteamFarm.Helpers {
|
|||
|
||||
return null;
|
||||
}
|
||||
#else
|
||||
throw new InvalidOperationException();
|
||||
#endif
|
||||
}
|
||||
|
||||
public enum ECryptoMethod : byte {
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
#if NETFRAMEWORK
|
||||
using OperatingSystem = JustArchiNET.Madness.OperatingSystemMadness.OperatingSystem;
|
||||
#endif
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
using System.Security.AccessControl;
|
||||
#endif
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.AccessControl;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ArchiSteamFarm.Core;
|
||||
|
@ -165,6 +167,7 @@ namespace ArchiSteamFarm.Helpers {
|
|||
if (!Directory.Exists(directoryPath)) {
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
if (OperatingSystem.IsWindows()) {
|
||||
DirectoryInfo directoryInfo = new(directoryPath);
|
||||
|
||||
|
@ -176,14 +179,20 @@ namespace ArchiSteamFarm.Helpers {
|
|||
// Non-critical, user might have no rights to manage the resource
|
||||
ASF.ArchiLogger.LogGenericDebuggingException(e);
|
||||
}
|
||||
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_GENERIC || !TARGET_WINDOWS
|
||||
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||
OS.UnixSetFileAccess(directoryPath, OS.EUnixPermission.Combined777);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
try {
|
||||
new FileStream(FilePath, FileMode.CreateNew).Dispose();
|
||||
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
if (OperatingSystem.IsWindows()) {
|
||||
FileInfo fileInfo = new(FilePath);
|
||||
|
||||
|
@ -195,9 +204,14 @@ namespace ArchiSteamFarm.Helpers {
|
|||
// Non-critical, user might have no rights to manage the resource
|
||||
ASF.ArchiLogger.LogGenericDebuggingException(e);
|
||||
}
|
||||
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_GENERIC || !TARGET_WINDOWS
|
||||
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||
OS.UnixSetFileAccess(FilePath, OS.EUnixPermission.Combined777);
|
||||
}
|
||||
#endif
|
||||
} catch (IOException) {
|
||||
// Ignored, if the file was already created in the meantime by another instance, this is fine
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#if NETFRAMEWORK
|
||||
using OperatingSystem = JustArchiNET.Madness.OperatingSystemMadness.OperatingSystem;
|
||||
#endif
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
using Microsoft.Win32;
|
||||
#endif
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
@ -42,7 +45,6 @@ using ArchiSteamFarm.NLog.Targets;
|
|||
using ArchiSteamFarm.Steam;
|
||||
using ArchiSteamFarm.Storage;
|
||||
using ArchiSteamFarm.Web;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
|
@ -274,9 +276,11 @@ namespace ArchiSteamFarm {
|
|||
// April Fools easter egg logic
|
||||
AprilFools.Init();
|
||||
|
||||
#if TARGET_GENERIC || TARGET_WINDOWS
|
||||
if (OperatingSystem.IsWindows()) {
|
||||
SystemEvents.TimeChanged += AprilFools.OnTimeChanged;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(latestJson)) {
|
||||
|
|
|
@ -34,6 +34,16 @@
|
|||
<DefineConstants>$(DefineConstants);ASF_VARIANT_$(ASFVariant.Replace('-', '_').ToUpperInvariant())</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net48' OR '$(RuntimeIdentifier)' == ''">
|
||||
<DefineConstants>$(DefineConstants);TARGET_GENERIC</DefineConstants>
|
||||
<TargetGeneric>true</TargetGeneric>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' != 'net48' AND ($(RuntimeIdentifier.StartsWith('win-')) OR $(RuntimeIdentifier.EndsWith('-windows')))">
|
||||
<DefineConstants>$(DefineConstants);TARGET_WINDOWS</DefineConstants>
|
||||
<TargetWindows>true</TargetWindows>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Default configuration for release builds -->
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<AssemblyOriginatorKeyFile>../resources/ArchiSteamFarm.snk.pub</AssemblyOriginatorKeyFile>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<PackageVersion Include="System.Linq.Async" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net48'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net48' AND ('$(TargetGeneric)' == 'true' OR '$(TargetWindows)' == 'true')">
|
||||
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="5.0.0" />
|
||||
<PackageVersion Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
|
||||
<PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="5.0.0" />
|
||||
|
|
Loading…
Reference in a new issue