From 1dc1fd83af979ed3bb4c9c2b6f67d9a76a7edb53 Mon Sep 17 00:00:00 2001
From: Jojo-1000 <33495614+Jojo-1000@users.noreply.github.com>
Date: Thu, 30 May 2024 00:49:23 +0200
Subject: [PATCH] Add SupportedOSPlatform attribute and target windows where
appropriate.
---
Duplicati.Library.RestAPI/LiveControls.cs | 3 +++
Duplicati.Library.RestAPI/RESTMethods/HyperV.cs | 2 ++
Duplicati.Library.RestAPI/RESTMethods/MSSQL.cs | 5 ++++-
Duplicati/Library/Common/IO/PosixFile.cs | 3 +++
Duplicati/Library/Common/IO/SystemIO.cs | 17 ++++++++++++++---
Duplicati/Library/Common/IO/SystemIOLinux.cs | 3 +++
Duplicati/Library/Common/IO/SystemIOWindows.cs | 2 ++
.../Library/Modules/Builtin/HyperVOptions.cs | 2 ++
.../Library/Modules/Builtin/MSSQLOptions.cs | 2 ++
Duplicati/Library/SQLiteHelper/SQLiteLoader.cs | 3 +++
Duplicati/Library/Snapshots/HyperVUtility.cs | 2 ++
Duplicati/Library/Snapshots/LinuxSnapshot.cs | 5 ++++-
Duplicati/Library/Snapshots/MSSQLUtility.cs | 2 ++
Duplicati/Library/Snapshots/NoSnapshotLinux.cs | 3 +++
.../Library/Snapshots/NoSnapshotWindows.cs | 2 ++
Duplicati/Library/Snapshots/SnapshotUtility.cs | 5 +++++
Duplicati/Library/Snapshots/USNJournal.cs | 2 ++
Duplicati/Library/Snapshots/Win32USN.cs | 2 ++
Duplicati/Library/Snapshots/WindowsSnapshot.cs | 3 ++-
Duplicati/Library/Utility/FilterGroups.cs | 2 ++
.../Utility/Power/LinuxPowerSupplyState.cs | 2 ++
.../Utility/Power/MacOSPowerSupplyState.cs | 2 ++
.../Utility/Power/WindowsPowerSupplyState.cs | 2 ++
Duplicati/Library/Utility/RegistryUtility.cs | 2 ++
Duplicati/Library/Utility/Utility.cs | 3 +++
Duplicati/WindowsService/WindowsService.csproj | 3 ++-
.../Duplicati.WindowsService.csproj | 3 ++-
.../net8/Duplicati.WindowsService/Program.cs | 2 ++
28 files changed, 81 insertions(+), 8 deletions(-)
diff --git a/Duplicati.Library.RestAPI/LiveControls.cs b/Duplicati.Library.RestAPI/LiveControls.cs
index 1a51636a3..a20c9d055 100644
--- a/Duplicati.Library.RestAPI/LiveControls.cs
+++ b/Duplicati.Library.RestAPI/LiveControls.cs
@@ -19,6 +19,7 @@
#endregion
using System;
using System.Collections.Generic;
+using System.Runtime.Versioning;
using System.Text;
using Duplicati.Library.Common;
using Duplicati.Library.RestAPI;
@@ -337,6 +338,7 @@ namespace Duplicati.Server
///
/// Method for calling a Win32 API
///
+ [SupportedOSPlatform("windows")]
private void RegisterHibernateMonitor()
{
Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
@@ -347,6 +349,7 @@ namespace Duplicati.Server
///
/// Unused sender parameter
/// The event information
+ [SupportedOSPlatform("windows")]
private void SystemEvents_PowerModeChanged(object sender, object _e)
{
Microsoft.Win32.PowerModeChangedEventArgs e = _e as Microsoft.Win32.PowerModeChangedEventArgs;
diff --git a/Duplicati.Library.RestAPI/RESTMethods/HyperV.cs b/Duplicati.Library.RestAPI/RESTMethods/HyperV.cs
index b957cfd48..2f10c86ee 100644
--- a/Duplicati.Library.RestAPI/RESTMethods/HyperV.cs
+++ b/Duplicati.Library.RestAPI/RESTMethods/HyperV.cs
@@ -25,6 +25,7 @@ using System.Linq;
using System.Security.Principal;
using Duplicati.Library.Snapshots;
using Duplicati.Library.Common;
+using System.Runtime.Versioning;
namespace Duplicati.Server.WebServer.RESTMethods
{
@@ -42,6 +43,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
// Make sure the JIT does not attempt to inline this call and thus load
// referenced types from System.Management here
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
private void RealGET(string key, RequestInfo info)
{
var hypervUtility = new HyperVUtility();
diff --git a/Duplicati.Library.RestAPI/RESTMethods/MSSQL.cs b/Duplicati.Library.RestAPI/RESTMethods/MSSQL.cs
index be873efdb..01ecceb7f 100644
--- a/Duplicati.Library.RestAPI/RESTMethods/MSSQL.cs
+++ b/Duplicati.Library.RestAPI/RESTMethods/MSSQL.cs
@@ -25,15 +25,17 @@ using System.Linq;
using System.Security.Principal;
using Duplicati.Library.Snapshots;
using Duplicati.Library.Common;
+using System.Runtime.Versioning;
namespace Duplicati.Server.WebServer.RESTMethods
{
+
public class MSSQL : IRESTMethodGET, IRESTMethodDocumented
{
public void GET(string key, RequestInfo info)
{
// Early exit in case we are non-windows to prevent attempting to load Windows-only components
- if (Platform.IsClientWindows)
+ if (OperatingSystem.IsWindows())
RealGET(key, info);
else
info.OutputOK(new string[0]);
@@ -42,6 +44,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
// Make sure the JIT does not attempt to inline this call and thus load
// referenced types from System.Management here
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
private void RealGET(string key, RequestInfo info)
{
var mssqlUtility = new MSSQLUtility();
diff --git a/Duplicati/Library/Common/IO/PosixFile.cs b/Duplicati/Library/Common/IO/PosixFile.cs
index 73b99240d..2ad8fb9bb 100644
--- a/Duplicati/Library/Common/IO/PosixFile.cs
+++ b/Duplicati/Library/Common/IO/PosixFile.cs
@@ -20,10 +20,13 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
+using System.Runtime.Versioning;
using Mono.Unix.Native;
namespace Duplicati.Library.Common.IO
{
+ [SupportedOSPlatform("linux")]
+ [SupportedOSPlatform("macOS")]
public static class PosixFile
{
diff --git a/Duplicati/Library/Common/IO/SystemIO.cs b/Duplicati/Library/Common/IO/SystemIO.cs
index 6aacceb23..95549add0 100644
--- a/Duplicati/Library/Common/IO/SystemIO.cs
+++ b/Duplicati/Library/Common/IO/SystemIO.cs
@@ -20,6 +20,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Common.IO
{
public static class SystemIO
@@ -28,17 +29,27 @@ namespace Duplicati.Library.Common.IO
///
/// A cached lookup for windows methods for dealing with long filenames
///
+ [SupportedOSPlatform("windows")]
public static readonly ISystemIO IO_WIN;
+ [SupportedOSPlatform("linux")]
+ [SupportedOSPlatform("macOS")]
public static readonly ISystemIO IO_SYS;
public static readonly ISystemIO IO_OS;
static SystemIO()
{
- IO_WIN = new SystemIOWindows();
- IO_SYS = new SystemIOLinux();
- IO_OS = Platform.IsClientWindows ? IO_WIN : IO_SYS;
+ if (OperatingSystem.IsWindows())
+ {
+ IO_WIN = new SystemIOWindows();
+ IO_OS = IO_WIN;
+ }
+ else if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux())
+ {
+ IO_SYS = new SystemIOLinux();
+ IO_OS = IO_SYS;
+ }
}
}
}
\ No newline at end of file
diff --git a/Duplicati/Library/Common/IO/SystemIOLinux.cs b/Duplicati/Library/Common/IO/SystemIOLinux.cs
index d3e70cab6..a7b302607 100644
--- a/Duplicati/Library/Common/IO/SystemIOLinux.cs
+++ b/Duplicati/Library/Common/IO/SystemIOLinux.cs
@@ -24,9 +24,12 @@ using System.IO;
using System.Linq;
using System.Collections.Generic;
using Duplicati.Library.Interface;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Common.IO
{
+ [SupportedOSPlatform("linux")]
+ [SupportedOSPlatform("macOS")]
public struct SystemIOLinux : ISystemIO
{
#region ISystemIO implementation
diff --git a/Duplicati/Library/Common/IO/SystemIOWindows.cs b/Duplicati/Library/Common/IO/SystemIOWindows.cs
index 1f48474fb..a7864815b 100644
--- a/Duplicati/Library/Common/IO/SystemIOWindows.cs
+++ b/Duplicati/Library/Common/IO/SystemIOWindows.cs
@@ -28,9 +28,11 @@ using System.Linq;
using AlphaFS = Alphaleonis.Win32.Filesystem;
using Duplicati.Library.Interface;
using Newtonsoft.Json;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Common.IO
{
+ [SupportedOSPlatform("windows")]
public struct SystemIOWindows : ISystemIO
{
// Based on the constant names used in
diff --git a/Duplicati/Library/Modules/Builtin/HyperVOptions.cs b/Duplicati/Library/Modules/Builtin/HyperVOptions.cs
index 4a56822ab..d242e77e7 100644
--- a/Duplicati/Library/Modules/Builtin/HyperVOptions.cs
+++ b/Duplicati/Library/Modules/Builtin/HyperVOptions.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using Duplicati.Library.Common;
using Duplicati.Library.Snapshots;
@@ -99,6 +100,7 @@ namespace Duplicati.Library.Modules.Builtin
// Make sure the JIT does not attempt to inline this call and thus load
// referenced types from System.Management here
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
private Dictionary RealParseSourcePaths(ref string[] paths, ref string filter, Dictionary commandlineOptions)
{
var changedOptions = new Dictionary();
diff --git a/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs b/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs
index 6bf5ebf19..184657171 100644
--- a/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs
+++ b/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using Duplicati.Library.Common;
using Duplicati.Library.Snapshots;
@@ -100,6 +101,7 @@ namespace Duplicati.Library.Modules.Builtin
// Make sure the JIT does not attempt to inline this call and thus load
// referenced types from System.Management here
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
private Dictionary RealParseSourcePaths(ref string[] paths, ref string filter, Dictionary commandlineOptions)
{
var changedOptions = new Dictionary();
diff --git a/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs b/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs
index 4c67027aa..48fa49930 100644
--- a/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs
+++ b/Duplicati/Library/SQLiteHelper/SQLiteLoader.cs
@@ -23,6 +23,7 @@
using System;
using System.IO;
+using System.Runtime.Versioning;
using Duplicati.Library.Common;
using Duplicati.Library.Common.IO;
using Duplicati.Library.Interface;
@@ -234,6 +235,8 @@ namespace Duplicati.Library.SQLiteHelper
/// The file to set permissions on.
/// Make sure we do not inline this, as we might eventually load Mono.Posix, which is not present on Windows
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("linux")]
+ [SupportedOSPlatform("macOS")]
private static void SetUnixPermissionUserRWOnly(string path)
{
var fi = PosixFile.GetUserGroupAndPermissions(path);
diff --git a/Duplicati/Library/Snapshots/HyperVUtility.cs b/Duplicati/Library/Snapshots/HyperVUtility.cs
index 896c9021c..32a686bb9 100644
--- a/Duplicati/Library/Snapshots/HyperVUtility.cs
+++ b/Duplicati/Library/Snapshots/HyperVUtility.cs
@@ -23,6 +23,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management;
+using System.Runtime.Versioning;
using Duplicati.Library.Common;
using Duplicati.Library.Common.IO;
@@ -81,6 +82,7 @@ namespace Duplicati.Library.Snapshots
}
}
+ [SupportedOSPlatform("windows")]
public class HyperVUtility
{
///
diff --git a/Duplicati/Library/Snapshots/LinuxSnapshot.cs b/Duplicati/Library/Snapshots/LinuxSnapshot.cs
index 2c7e6ad98..90ad78390 100644
--- a/Duplicati/Library/Snapshots/LinuxSnapshot.cs
+++ b/Duplicati/Library/Snapshots/LinuxSnapshot.cs
@@ -23,6 +23,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Runtime.Versioning;
using System.Text;
using Duplicati.Library.Common.IO;
@@ -35,12 +36,14 @@ namespace Duplicati.Library.Snapshots
/// The class presents all files and folders with their regular filenames to the caller,
/// and internally handles the conversion to the snapshot path.
///
+ [SupportedOSPlatform("linux")]
+ [SupportedOSPlatform("macOS")]
public sealed class LinuxSnapshot : SnapshotBase
{
///
/// The tag used for logging messages
///
- public static readonly string LOGTAG = Logging.Log.LogTagFromType();
+ public static readonly string LOGTAG = Logging.Log.LogTagFromType(typeof(WindowsSnapshot));
///
/// This is a lookup, mapping each source folder to the corresponding snapshot
diff --git a/Duplicati/Library/Snapshots/MSSQLUtility.cs b/Duplicati/Library/Snapshots/MSSQLUtility.cs
index 322a8270a..78a5ecee5 100644
--- a/Duplicati/Library/Snapshots/MSSQLUtility.cs
+++ b/Duplicati/Library/Snapshots/MSSQLUtility.cs
@@ -23,6 +23,7 @@ using Duplicati.Library.Common.IO;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Snapshots
{
@@ -81,6 +82,7 @@ namespace Duplicati.Library.Snapshots
}
}
+ [SupportedOSPlatform("windows")]
public class MSSQLUtility
{
///
diff --git a/Duplicati/Library/Snapshots/NoSnapshotLinux.cs b/Duplicati/Library/Snapshots/NoSnapshotLinux.cs
index 32dc317f7..0f6318586 100644
--- a/Duplicati/Library/Snapshots/NoSnapshotLinux.cs
+++ b/Duplicati/Library/Snapshots/NoSnapshotLinux.cs
@@ -20,6 +20,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.Runtime.Versioning;
using Duplicati.Library.Common.IO;
namespace Duplicati.Library.Snapshots
@@ -27,6 +28,8 @@ namespace Duplicati.Library.Snapshots
///
/// Handler for providing a snapshot like access to files and folders
///
+ [SupportedOSPlatform("linux")]
+ [SupportedOSPlatform("macOS")]
public sealed class NoSnapshotLinux : SnapshotBase
{
///
diff --git a/Duplicati/Library/Snapshots/NoSnapshotWindows.cs b/Duplicati/Library/Snapshots/NoSnapshotWindows.cs
index 2c5fa92b6..44e81a849 100644
--- a/Duplicati/Library/Snapshots/NoSnapshotWindows.cs
+++ b/Duplicati/Library/Snapshots/NoSnapshotWindows.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Versioning;
using Duplicati.Library.Common.IO;
namespace Duplicati.Library.Snapshots
@@ -29,6 +30,7 @@ namespace Duplicati.Library.Snapshots
///
/// Handler for providing a snapshot like access to files and folders
///
+ [SupportedOSPlatform("windows")]
public sealed class NoSnapshotWindows : SnapshotBase
{
///
diff --git a/Duplicati/Library/Snapshots/SnapshotUtility.cs b/Duplicati/Library/Snapshots/SnapshotUtility.cs
index ea0a16b8f..ac76bfd20 100644
--- a/Duplicati/Library/Snapshots/SnapshotUtility.cs
+++ b/Duplicati/Library/Snapshots/SnapshotUtility.cs
@@ -20,8 +20,10 @@
// DEALINGS IN THE SOFTWARE.
+using System;
using System.Collections.Generic;
using System.IO;
+using System.Runtime.Versioning;
using Duplicati.Library.Common;
using Duplicati.Library.Common.IO;
@@ -57,6 +59,8 @@ namespace Duplicati.Library.Snapshots
/// The list of folders to create snapshots of
/// The ISnapshotService implementation
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("linux")]
+ [SupportedOSPlatform("macOS")]
private static ISnapshotService CreateLinuxSnapshot(IEnumerable folders)
{
return new LinuxSnapshot(folders);
@@ -69,6 +73,7 @@ namespace Duplicati.Library.Snapshots
/// A set of commandline options
/// The ISnapshotService implementation
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
private static ISnapshotService CreateWindowsSnapshot(IEnumerable folders, Dictionary options)
{
return new WindowsSnapshot(folders, options);
diff --git a/Duplicati/Library/Snapshots/USNJournal.cs b/Duplicati/Library/Snapshots/USNJournal.cs
index d185946ec..d0c7e9d9d 100644
--- a/Duplicati/Library/Snapshots/USNJournal.cs
+++ b/Duplicati/Library/Snapshots/USNJournal.cs
@@ -28,6 +28,7 @@ using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
+using System.Runtime.Versioning;
using Duplicati.Library.Common;
using Duplicati.Library.Common.IO;
using Microsoft.Win32.SafeHandles;
@@ -37,6 +38,7 @@ namespace Duplicati.Library.Snapshots
///
/// Class that encapsulates USN journal access to a single volume
///
+ [SupportedOSPlatform("windows")]
public sealed class USNJournal : IDisposable
{
///
diff --git a/Duplicati/Library/Snapshots/Win32USN.cs b/Duplicati/Library/Snapshots/Win32USN.cs
index 1d3d1c4b1..f6bf56a8b 100644
--- a/Duplicati/Library/Snapshots/Win32USN.cs
+++ b/Duplicati/Library/Snapshots/Win32USN.cs
@@ -21,6 +21,7 @@
using System;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using Microsoft.Win32.SafeHandles;
namespace Duplicati.Library.Snapshots
@@ -30,6 +31,7 @@ namespace Duplicati.Library.Snapshots
///
/// Various Windows specific calls to support USN
///
+ [SupportedOSPlatform("windows")]
internal static class Win32USN
{
public const int ERROR_HANDLE_EOF = 38;
diff --git a/Duplicati/Library/Snapshots/WindowsSnapshot.cs b/Duplicati/Library/Snapshots/WindowsSnapshot.cs
index b6e0e179f..63b568f06 100644
--- a/Duplicati/Library/Snapshots/WindowsSnapshot.cs
+++ b/Duplicati/Library/Snapshots/WindowsSnapshot.cs
@@ -24,7 +24,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-
+using System.Runtime.Versioning;
using Duplicati.Library.Common.IO;
namespace Duplicati.Library.Snapshots
@@ -36,6 +36,7 @@ namespace Duplicati.Library.Snapshots
/// The class presents all files and folders with their regular filenames to the caller,
/// and internally handles the conversion to the shadow path.
///
+ [SupportedOSPlatform("windows")]
public sealed class WindowsSnapshot : SnapshotBase
{
///
diff --git a/Duplicati/Library/Utility/FilterGroups.cs b/Duplicati/Library/Utility/FilterGroups.cs
index 4b4d44d83..5cb191d5e 100644
--- a/Duplicati/Library/Utility/FilterGroups.cs
+++ b/Duplicati/Library/Utility/FilterGroups.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Versioning;
using System.Xml.Linq;
using Duplicati.Library.Common;
@@ -719,6 +720,7 @@ namespace Duplicati.Library.Utility
///
/// The list of paths to exclude.
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
private static string[] GetWindowsRegistryFiltersInternal()
{
var rk = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Default);
diff --git a/Duplicati/Library/Utility/Power/LinuxPowerSupplyState.cs b/Duplicati/Library/Utility/Power/LinuxPowerSupplyState.cs
index 318cf6733..6a94a170e 100644
--- a/Duplicati/Library/Utility/Power/LinuxPowerSupplyState.cs
+++ b/Duplicati/Library/Utility/Power/LinuxPowerSupplyState.cs
@@ -22,9 +22,11 @@
using System;
using System.IO;
using System.Linq;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Utility.Power
{
+ [SupportedOSPlatform("linux")]
public class LinuxPowerSupplyState : IPowerSupplyState
{
private readonly string sysfsPath = Path.Combine("/", "sys", "class", "power_supply");
diff --git a/Duplicati/Library/Utility/Power/MacOSPowerSupplyState.cs b/Duplicati/Library/Utility/Power/MacOSPowerSupplyState.cs
index e55158521..0d53c1419 100644
--- a/Duplicati/Library/Utility/Power/MacOSPowerSupplyState.cs
+++ b/Duplicati/Library/Utility/Power/MacOSPowerSupplyState.cs
@@ -21,9 +21,11 @@
using System;
using System.Linq;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Utility.Power
{
+ [SupportedOSPlatform("macOS")]
public class MacOSPowerSupplyState : IPowerSupplyState
{
public PowerSupply.Source GetSource()
diff --git a/Duplicati/Library/Utility/Power/WindowsPowerSupplyState.cs b/Duplicati/Library/Utility/Power/WindowsPowerSupplyState.cs
index ab7732c8f..be41261ca 100644
--- a/Duplicati/Library/Utility/Power/WindowsPowerSupplyState.cs
+++ b/Duplicati/Library/Utility/Power/WindowsPowerSupplyState.cs
@@ -20,9 +20,11 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Utility.Power
{
+ [SupportedOSPlatform("windows")]
public class WindowsPowerSupplyState : IPowerSupplyState
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
diff --git a/Duplicati/Library/Utility/RegistryUtility.cs b/Duplicati/Library/Utility/RegistryUtility.cs
index 4804d261f..fbeee23d9 100644
--- a/Duplicati/Library/Utility/RegistryUtility.cs
+++ b/Duplicati/Library/Utility/RegistryUtility.cs
@@ -20,9 +20,11 @@
// DEALINGS IN THE SOFTWARE.
using Microsoft.Win32;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Utility
{
+ [SupportedOSPlatform("windows")]
public static class RegistryUtility
{
public static string GetDataByValueName(string parentKeyName, string name)
diff --git a/Duplicati/Library/Utility/Utility.cs b/Duplicati/Library/Utility/Utility.cs
index 3e001906f..2ba92d0e2 100644
--- a/Duplicati/Library/Utility/Utility.cs
+++ b/Duplicati/Library/Utility/Utility.cs
@@ -31,6 +31,7 @@ using Duplicati.Library.Common.IO;
using Duplicati.Library.Common;
using System.Globalization;
using System.Security.Cryptography;
+using System.Runtime.Versioning;
namespace Duplicati.Library.Utility
{
@@ -1314,6 +1315,7 @@ namespace Duplicati.Library.Utility
/// Volume guid
/// Drive letter, as a single character, or null if the volume wasn't found
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
public static string GetDriveLetterFromVolumeGuid(Guid volumeGuid)
{
// Based on this answer:
@@ -1348,6 +1350,7 @@ namespace Duplicati.Library.Utility
///
/// Pairs of drive letter to volume guids
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [SupportedOSPlatform("windows")]
public static IEnumerable> GetVolumeGuidsAndDriveLetters()
{
using (var searcher = new System.Management.ManagementObjectSearcher("Select * from Win32_Volume"))
diff --git a/Duplicati/WindowsService/WindowsService.csproj b/Duplicati/WindowsService/WindowsService.csproj
index 96fd61bb8..62f9161e4 100644
--- a/Duplicati/WindowsService/WindowsService.csproj
+++ b/Duplicati/WindowsService/WindowsService.csproj
@@ -1,8 +1,9 @@
- net8.0
+ net8.0-windows10.0.17763.0
Duplicati.WindowsService.Implementation
+ 7.0
diff --git a/Executables/net8/Duplicati.WindowsService/Duplicati.WindowsService.csproj b/Executables/net8/Duplicati.WindowsService/Duplicati.WindowsService.csproj
index b0b830e20..dbcea05af 100644
--- a/Executables/net8/Duplicati.WindowsService/Duplicati.WindowsService.csproj
+++ b/Executables/net8/Duplicati.WindowsService/Duplicati.WindowsService.csproj
@@ -2,9 +2,10 @@
Exe
- net8.0
+ net8.0-windows10.0.17763.0
WindowsService for Duplicati
Duplicati.WindowsService
+ 7.0
diff --git a/Executables/net8/Duplicati.WindowsService/Program.cs b/Executables/net8/Duplicati.WindowsService/Program.cs
index 61961d8e0..e5d98988c 100644
--- a/Executables/net8/Duplicati.WindowsService/Program.cs
+++ b/Executables/net8/Duplicati.WindowsService/Program.cs
@@ -1,3 +1,5 @@
+using System.Runtime.Versioning;
+
namespace Duplicati.WindowsService.Net8
{
// Wrapper class to keep code independent