From 9c72a094516fb4be51bf54550f36824bbca17865 Mon Sep 17 00:00:00 2001 From: wherewhere Date: Thu, 23 Mar 2023 17:05:14 +0800 Subject: [PATCH] Add FullTargets prop to support netcore and uap --- .../AdbCommandLineClient.cs | 2 +- .../AdvancedSharpAdbClient.csproj | 19 ++++++++++++++++--- AdvancedSharpAdbClient/DeviceMonitor.cs | 2 +- .../Exceptions/AdbException.cs | 4 ++-- .../Exceptions/CommandAbortingException.cs | 4 ++-- .../PackageInstallationException.cs | 4 ++-- .../Exceptions/PermissionDeniedException.cs | 4 ++-- .../Exceptions/UnknownOptionException.cs | 4 ++-- .../Extensions/CrossPlatformFunc.cs | 2 +- .../Extensions/TaskToApm.cs | 2 +- .../Extensions/Utilities.cs | 6 +++--- .../Models/FramebufferHeader.cs | 2 +- Directory.Build.props | 1 + 13 files changed, 35 insertions(+), 21 deletions(-) diff --git a/AdvancedSharpAdbClient/AdbCommandLineClient.cs b/AdvancedSharpAdbClient/AdbCommandLineClient.cs index dfbf2012..ebb30b2b 100644 --- a/AdvancedSharpAdbClient/AdbCommandLineClient.cs +++ b/AdvancedSharpAdbClient/AdbCommandLineClient.cs @@ -130,7 +130,7 @@ public void StartServer() return; } -#if !NETSTANDARD1_3 +#if HAS_Process // Starting the adb server failed for whatever reason. This can happen if adb.exe // is running but is not accepting requests. In that case, try to kill it & start again. // It kills all processes named "adb", so let's hope nobody else named their process that way. diff --git a/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj b/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj index ee9b5b7f..ab231f03 100644 --- a/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj +++ b/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj @@ -1,6 +1,11 @@  - + + NU1603 + net3.5-client;net4.0-client;net4.5.2;net4.6.2;net4.7.2;net4.8.1;net6.0;netcore50;netcoreapp3.1;netstandard1.3;netstandard2.0;uap10.0 + + + netstandard2.0 net3.5-client;net4.0-client;net4.5.2;net4.6.2;net4.7.2;net4.8.1;net6.0;netcoreapp3.1;netstandard1.3;netstandard2.0 net6.0;netcoreapp3.1;netstandard1.3;netstandard2.0 @@ -30,7 +35,8 @@ - + @@ -39,6 +45,7 @@ @@ -64,10 +71,16 @@ and '$(TargetFramework)' != 'net4.0-client'"> $(DefineConstants);HAS_LOGGER - + $(DefineConstants);HAS_OLDLOGGER + + $(DefineConstants);HAS_Process + + diff --git a/AdvancedSharpAdbClient/DeviceMonitor.cs b/AdvancedSharpAdbClient/DeviceMonitor.cs index 4a984ca1..c8f11886 100644 --- a/AdvancedSharpAdbClient/DeviceMonitor.cs +++ b/AdvancedSharpAdbClient/DeviceMonitor.cs @@ -158,7 +158,7 @@ public void Dispose() monitorTaskCancellationTokenSource.Cancel(); monitorTask.Wait(); -#if !NETSTANDARD1_3 +#if HAS_Process monitorTask.Dispose(); #endif monitorTask = null; diff --git a/AdvancedSharpAdbClient/Exceptions/AdbException.cs b/AdvancedSharpAdbClient/Exceptions/AdbException.cs index e4821a37..b643656e 100644 --- a/AdvancedSharpAdbClient/Exceptions/AdbException.cs +++ b/AdvancedSharpAdbClient/Exceptions/AdbException.cs @@ -52,13 +52,13 @@ public AdbException(string message, AdbResponse response) : base(message) /// The serialization info. /// The context. public AdbException(SerializationInfo serializationInfo, StreamingContext context) : -#if !NETSTANDARD1_3 +#if HAS_Process base(serializationInfo, context) #else base(serializationInfo.GetString("Message")) #endif { -#if NETSTANDARD1_3 +#if !HAS_Process HelpLink = serializationInfo.GetString("HelpURL"); // Do not rename (binary serialization) HResult = serializationInfo.GetInt32("HResult"); // Do not rename (binary serialization) Source = serializationInfo.GetString("Source"); // Do not rename (binary serialization) diff --git a/AdvancedSharpAdbClient/Exceptions/CommandAbortingException.cs b/AdvancedSharpAdbClient/Exceptions/CommandAbortingException.cs index 4e1d7c22..c0a2e583 100644 --- a/AdvancedSharpAdbClient/Exceptions/CommandAbortingException.cs +++ b/AdvancedSharpAdbClient/Exceptions/CommandAbortingException.cs @@ -33,13 +33,13 @@ public CommandAbortingException(string message) : base(message) /// The serialization info. /// The context. public CommandAbortingException(SerializationInfo serializationInfo, StreamingContext context) : -#if !NETSTANDARD1_3 +#if HAS_Process base(serializationInfo, context) #else base(serializationInfo.GetString("Message")) #endif { -#if NETSTANDARD1_3 +#if !HAS_Process HelpLink = serializationInfo.GetString("HelpURL"); // Do not rename (binary serialization) HResult = serializationInfo.GetInt32("HResult"); // Do not rename (binary serialization) Source = serializationInfo.GetString("Source"); // Do not rename (binary serialization) diff --git a/AdvancedSharpAdbClient/Exceptions/PackageInstallationException.cs b/AdvancedSharpAdbClient/Exceptions/PackageInstallationException.cs index 599c7c04..0fc0d26d 100644 --- a/AdvancedSharpAdbClient/Exceptions/PackageInstallationException.cs +++ b/AdvancedSharpAdbClient/Exceptions/PackageInstallationException.cs @@ -45,13 +45,13 @@ public PackageInstallationException(string message, Exception inner) : base(mess /// The parameter is null. /// The class name is null or is zero (0). protected PackageInstallationException(SerializationInfo info, StreamingContext context) : -#if !NETSTANDARD1_3 +#if HAS_Process base(info, context) #else base(info.GetString("Message")) #endif { -#if NETSTANDARD1_3 +#if !HAS_Process HelpLink = info.GetString("HelpURL"); // Do not rename (binary serialization) HResult = info.GetInt32("HResult"); // Do not rename (binary serialization) Source = info.GetString("Source"); // Do not rename (binary serialization) diff --git a/AdvancedSharpAdbClient/Exceptions/PermissionDeniedException.cs b/AdvancedSharpAdbClient/Exceptions/PermissionDeniedException.cs index dc6d3eba..902aec1f 100644 --- a/AdvancedSharpAdbClient/Exceptions/PermissionDeniedException.cs +++ b/AdvancedSharpAdbClient/Exceptions/PermissionDeniedException.cs @@ -33,13 +33,13 @@ public PermissionDeniedException(string message) : base(message) /// The serialization info. /// The context. public PermissionDeniedException(SerializationInfo serializationInfo, StreamingContext context) : -#if !NETSTANDARD1_3 +#if HAS_Process base(serializationInfo, context) #else base(serializationInfo.GetString("Message")) #endif { -#if NETSTANDARD1_3 +#if !HAS_Process HelpLink = serializationInfo.GetString("HelpURL"); // Do not rename (binary serialization) HResult = serializationInfo.GetInt32("HResult"); // Do not rename (binary serialization) Source = serializationInfo.GetString("Source"); // Do not rename (binary serialization) diff --git a/AdvancedSharpAdbClient/Exceptions/UnknownOptionException.cs b/AdvancedSharpAdbClient/Exceptions/UnknownOptionException.cs index 13769001..b47d43b6 100644 --- a/AdvancedSharpAdbClient/Exceptions/UnknownOptionException.cs +++ b/AdvancedSharpAdbClient/Exceptions/UnknownOptionException.cs @@ -33,13 +33,13 @@ public UnknownOptionException(string message) : base(message) /// The serialization info. /// The context. public UnknownOptionException(SerializationInfo serializationInfo, StreamingContext context) : -#if !NETSTANDARD1_3 +#if HAS_Process base(serializationInfo, context) #else base(serializationInfo.GetString("Message")) #endif { -#if NETSTANDARD1_3 +#if !HAS_Process HelpLink = serializationInfo.GetString("HelpURL"); // Do not rename (binary serialization) HResult = serializationInfo.GetInt32("HResult"); // Do not rename (binary serialization) Source = serializationInfo.GetString("Source"); // Do not rename (binary serialization) diff --git a/AdvancedSharpAdbClient/Extensions/CrossPlatformFunc.cs b/AdvancedSharpAdbClient/Extensions/CrossPlatformFunc.cs index a07902bc..9f166bdd 100644 --- a/AdvancedSharpAdbClient/Extensions/CrossPlatformFunc.cs +++ b/AdvancedSharpAdbClient/Extensions/CrossPlatformFunc.cs @@ -25,7 +25,7 @@ public static class CrossPlatformFunc /// The return code of the process. public static Func, List, int> RunProcess = (string filename, string command, List errorOutput, List standardOutput) => { -#if !NETSTANDARD1_3 +#if HAS_Process ProcessStartInfo psi = new(filename, command) { CreateNoWindow = true, diff --git a/AdvancedSharpAdbClient/Extensions/TaskToApm.cs b/AdvancedSharpAdbClient/Extensions/TaskToApm.cs index efe4a450..0d5558b4 100644 --- a/AdvancedSharpAdbClient/Extensions/TaskToApm.cs +++ b/AdvancedSharpAdbClient/Extensions/TaskToApm.cs @@ -1,4 +1,4 @@ -#if NETSTANDARD1_3 +#if !HAS_Process // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. diff --git a/AdvancedSharpAdbClient/Extensions/Utilities.cs b/AdvancedSharpAdbClient/Extensions/Utilities.cs index 1ee02ce6..8633d3ae 100644 --- a/AdvancedSharpAdbClient/Extensions/Utilities.cs +++ b/AdvancedSharpAdbClient/Extensions/Utilities.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using System.Threading; -#if NETSTANDARD1_3 +#if !HAS_Process using System.Net.Sockets; #endif @@ -149,7 +149,7 @@ public static long ToUnixTimeSeconds(this DateTimeOffset dateTimeOffset) => (int)dateTimeOffset.ToUnixTimeSeconds(); #endif -#if NETSTANDARD1_3 +#if !HAS_Process /// /// Begins to asynchronously receive data from a connected . /// @@ -166,7 +166,7 @@ public static IAsyncResult BeginReceive(this Socket socket, byte[] buffer, int o TaskToApm.Begin(socket.ReceiveAsync(buffer, offset, size, socketFlags, default), callback, state); #endif -#if NETSTANDARD1_3 +#if !HAS_Process /// /// Ends a pending asynchronous read. /// diff --git a/AdvancedSharpAdbClient/Models/FramebufferHeader.cs b/AdvancedSharpAdbClient/Models/FramebufferHeader.cs index fda086b7..a836fb76 100644 --- a/AdvancedSharpAdbClient/Models/FramebufferHeader.cs +++ b/AdvancedSharpAdbClient/Models/FramebufferHeader.cs @@ -165,7 +165,7 @@ public Image ToImage(byte[] buffer) // The pixel format of the framebuffer may not be one that .NET recognizes, so we need to fix that PixelFormat pixelFormat = StandardizePixelFormat(buffer); -#if !NETSTANDARD1_3 +#if HAS_Process Bitmap bitmap = new((int)Width, (int)Height, pixelFormat); BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, pixelFormat); Marshal.Copy(buffer, 0, bitmapData.Scan0, buffer.Length); diff --git a/Directory.Build.props b/Directory.Build.props index 78d9d9db..feb8d5db 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -22,6 +22,7 @@ + False False True