Skip to content

Commit

Permalink
Add FullTargets prop to support netcore and uap
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Mar 23, 2023
1 parent 77b22cc commit 9c72a09
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient/AdbCommandLineClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 16 additions & 3 deletions AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PropertyGroup Condition="'$(FullTargets)' == 'true'">
<NoWarn>NU1603</NoWarn>
<TargetFrameworks>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</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(FullTargets)' != 'true'">
<TargetFramework Condition="'$(GITHUB_ACTIONS)' == 'true'">netstandard2.0</TargetFramework>
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'true' And '$(IsWindows)'">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</TargetFrameworks>
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'true' And !'$(IsWindows)'">net6.0;netcoreapp3.1;netstandard1.3;netstandard2.0</TargetFrameworks>
Expand Down Expand Up @@ -30,7 +35,8 @@
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<ItemGroup Condition="'$(TargetFramework)' == 'netcore50'
or '$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Drawing-dotnet-core" Version="1.2.3" />
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
Expand All @@ -39,6 +45,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net4.5.2'
or '$(TargetFramework)' == 'netcore50'
or '$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" />
</ItemGroup>
Expand All @@ -64,10 +71,16 @@
and '$(TargetFramework)' != 'net4.0-client'">
<DefineConstants>$(DefineConstants);HAS_LOGGER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net4.5.2'
or '$(TargetFramework)' == 'netcore50'
or '$(TargetFramework)' == 'netstandard1.3'">
<DefineConstants>$(DefineConstants);HAS_OLDLOGGER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' != 'netcore50'
and '$(TargetFramework)' != 'netstandard1.3'">
<DefineConstants>$(DefineConstants);HAS_Process</DefineConstants>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient/DeviceMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void Dispose()
monitorTaskCancellationTokenSource.Cancel();
monitorTask.Wait();

#if !NETSTANDARD1_3
#if HAS_Process
monitorTask.Dispose();
#endif
monitorTask = null;
Expand Down
4 changes: 2 additions & 2 deletions AdvancedSharpAdbClient/Exceptions/AdbException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public AdbException(string message, AdbResponse response) : base(message)
/// <param name="serializationInfo">The serialization info.</param>
/// <param name="context">The context.</param>
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)
Expand Down
4 changes: 2 additions & 2 deletions AdvancedSharpAdbClient/Exceptions/CommandAbortingException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public CommandAbortingException(string message) : base(message)
/// <param name="serializationInfo">The serialization info.</param>
/// <param name="context">The context.</param>
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public PackageInstallationException(string message, Exception inner) : base(mess
/// <exception cref="ArgumentNullException">The <paramref name="info"/> parameter is null.</exception>
/// <exception cref="SerializationException">The class name is null or <see cref="Exception.HResult"/> is zero (0).</exception>
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public PermissionDeniedException(string message) : base(message)
/// <param name="serializationInfo">The serialization info.</param>
/// <param name="context">The context.</param>
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)
Expand Down
4 changes: 2 additions & 2 deletions AdvancedSharpAdbClient/Exceptions/UnknownOptionException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public UnknownOptionException(string message) : base(message)
/// <param name="serializationInfo">The serialization info.</param>
/// <param name="context">The context.</param>
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)
Expand Down
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient/Extensions/CrossPlatformFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class CrossPlatformFunc
/// <returns>The return code of the process.</returns>
public static Func<string, string, List<string>, List<string>, int> RunProcess = (string filename, string command, List<string> errorOutput, List<string> standardOutput) =>
{
#if !NETSTANDARD1_3
#if HAS_Process
ProcessStartInfo psi = new(filename, command)
{
CreateNoWindow = true,
Expand Down
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient/Extensions/TaskToApm.cs
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
6 changes: 3 additions & 3 deletions AdvancedSharpAdbClient/Extensions/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Threading.Tasks;
using System.Threading;

#if NETSTANDARD1_3
#if !HAS_Process
using System.Net.Sockets;
#endif

Expand Down Expand Up @@ -149,7 +149,7 @@ public static long ToUnixTimeSeconds(this DateTimeOffset dateTimeOffset) =>
(int)dateTimeOffset.ToUnixTimeSeconds();
#endif

#if NETSTANDARD1_3
#if !HAS_Process
/// <summary>
/// Begins to asynchronously receive data from a connected <see cref="Socket"/>.
/// </summary>
Expand All @@ -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
/// <summary>
/// Ends a pending asynchronous read.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion AdvancedSharpAdbClient/Models/FramebufferHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</PropertyGroup>

<PropertyGroup>
<FullTargets Condition="'$(FullTargets)' == ''">False</FullTargets>
<IsWindows Condition="'$(IsWindows)' == ''">False</IsWindows>
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows')) == 'true' OR '$(Platform)' == 'Windows NT'">True</IsWindows>
</PropertyGroup>
Expand Down

0 comments on commit 9c72a09

Please sign in to comment.