Skip to content

Commit 894a91f

Browse files
committed
Use IsTargetFrameworkCompatible to set target
1 parent 0d6bccf commit 894a91f

27 files changed

+112
-111
lines changed

AdvancedSharpAdbClient/AdbClient.Async.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public async Task ExecuteRemoteCommandAsync(string command, DeviceData device, I
256256
await ExecuteServerCommandAsync("shell", command, socket, receiver, encoding, cancellationToken);
257257
}
258258

259-
#if NETCOREAPP3_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
259+
#if COMP_NETSTANDARD2_1
260260
/// <inheritdoc/>
261261
public async IAsyncEnumerable<string> ExecuteServerCommandAsync(string target, string command, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken = default)
262262
{
@@ -345,7 +345,7 @@ public async IAsyncEnumerable<LogEntry> RunLogServiceAsync(DeviceData device, [E
345345
await socket.SendAdbRequestAsync(request.ToString(), cancellationToken).ConfigureAwait(false);
346346
_ = await socket.ReadAdbResponseAsync(cancellationToken).ConfigureAwait(false);
347347

348-
#if NETCOREAPP3_0_OR_GREATER
348+
#if COMP_NETSTANDARD2_1
349349
await
350350
#endif
351351
using Stream stream = socket.GetShellStream();
@@ -397,7 +397,7 @@ public async Task RunLogServiceAsync(DeviceData device, Action<LogEntry> message
397397
await socket.SendAdbRequestAsync(request.ToString(), cancellationToken).ConfigureAwait(false);
398398
_ = await socket.ReadAdbResponseAsync(cancellationToken).ConfigureAwait(false);
399399

400-
#if NETCOREAPP3_0_OR_GREATER
400+
#if COMP_NETSTANDARD2_1
401401
await
402402
#endif
403403
using Stream stream = socket.GetShellStream();
@@ -932,7 +932,7 @@ public async Task InstallCommitAsync(DeviceData device, string session, Cancella
932932
}
933933
}
934934

935-
#if WINDOWS_UWP || WINDOWS10_0_17763_0_OR_GREATER
935+
#if HAS_WINRT
936936
/// <inheritdoc/>
937937
[ContractVersion(typeof(UniversalApiContract), 65536u)]
938938
public virtual async Task InstallAsync(DeviceData device, IRandomAccessStream apk, Action<InstallProgressEventArgs>? callback = null, CancellationToken cancellationToken = default, params string[] arguments)

AdvancedSharpAdbClient/AdbClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace AdvancedSharpAdbClient
3131
/// </remarks>
3232
[DebuggerDisplay($"{nameof(AdbClient)} \\{{ {nameof(EndPoint)} = {{{nameof(EndPoint)}}} }}")]
3333
public partial class AdbClient : IAdbClient, ICloneable<AdbClient>, ICloneable
34-
#if WINDOWS_UWP || WINDOWS10_0_17763_0_OR_GREATER
34+
#if HAS_WINRT
3535
, IAdbClient.IWinRT
3636
#endif
3737
{

AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj

Lines changed: 44 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
<PropertyGroup>
1414
<PackageId>$(AssemblyName).Standard</PackageId>
1515
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
16-
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0-client;net4.5</TargetFrameworks>
16+
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0;net4.5</TargetFrameworks>
1717
</PropertyGroup>
1818
</When>
1919
<When Condition="'$(FullTargets)' == 'True'">
2020
<PropertyGroup>
2121
<NoWarn>$(NoWarn);NU1603;NU1605;NU1902;NU1903</NoWarn>
2222
<TargetFrameworks>net6.0;net8.0;netcoreapp2.1;netcoreapp3.1;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
23-
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0-client;net3.5-client;net4.0-client;net4.5;net4.6.1;net4.8;net6.0-windows10.0.17763.0;net8.0-windows10.0.17763.0</TargetFrameworks>
23+
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0;net3.5-client;net4.0-client;net4.5;net4.6.1;net4.8;net6.0-windows10.0.17763.0;net8.0-windows10.0.17763.0</TargetFrameworks>
2424
<TargetFrameworks Condition="'$(GITHUB_ACTIONS)' != 'True' and '$(IsWindows)' == 'True'">$(TargetFrameworks);netcore5.0;uap10.0;uap10.0.15138.0</TargetFrameworks>
2525
</PropertyGroup>
2626
</When>
2727
<Otherwise>
2828
<PropertyGroup>
2929
<TargetFrameworks>net8.0;netcoreapp3.1;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
30-
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0-client;net3.5-client;net4.5;net4.8;net8.0-windows10.0.17763.0</TargetFrameworks>
30+
<TargetFrameworks Condition="'$(IsWindows)' == 'True'">$(TargetFrameworks);net2.0;net3.5-client;net4.5;net4.8;net8.0-windows10.0.17763.0</TargetFrameworks>
3131
</PropertyGroup>
3232
</Otherwise>
3333
</Choose>
@@ -72,8 +72,8 @@
7272
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
7373
</ItemGroup>
7474

75-
<ItemGroup Condition="'$(TargetFramework)' == 'net2.0-client'
76-
or '$(TargetFramework)' == 'net3.0-client'">
75+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net2.0'))
76+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net3.5-client'))">
7777
<PackageReference Include="LinqBridge" Version="1.3.0" />
7878
</ItemGroup>
7979

@@ -89,104 +89,75 @@
8989
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
9090
</ItemGroup>
9191

92-
<ItemGroup Condition="'$(TargetFramework)' == 'netcore5.0'
93-
or '$(TargetFramework)' == 'netstandard1.3'
94-
or '$(TargetFramework)' == 'uap10.0'">
92+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard1.1'))
93+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net1.1'))
94+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp1.0'))
95+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.0'))">
9596
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
9697
</ItemGroup>
9798

98-
<ItemGroup Condition="'$(TargetFramework)' == 'netcore5.0'
99-
or '$(TargetFramework)' == 'netcoreapp1.0'
100-
or '$(TargetFramework)' == 'netcoreapp1.1'
101-
or '$(TargetFramework)' == 'netstandard1.3'
102-
or '$(TargetFramework)' == 'uap10.0'">
99+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard1.3'))
100+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net1.1'))
101+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.0'))">
103102
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
104103
</ItemGroup>
105104

106-
<ItemGroup Condition="'$(TargetFramework)' == 'net4.6.1'
107-
or '$(TargetFramework)' == 'net4.8'
108-
or '$(TargetFramework)' == 'netstandard2.0'
109-
or '$(TargetFramework)' == 'uap10.0.15138.0'">
105+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.0'))
106+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.1'))
107+
and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.1'))">
110108
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
111109
</ItemGroup>
112110

113-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-windows10.0.17763.0'
114-
or '$(TargetFramework)' == 'net8.0-windows10.0.17763.0'">
111+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0-windows'))">
115112
<PackageReference Include="System.Drawing.Common" Version="8.0.6" />
116113
</ItemGroup>
114+
115+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.1'))">
116+
<DefineConstants>$(DefineConstants);COMP_NETSTANDARD2_1</DefineConstants>
117+
</PropertyGroup>
117118

118-
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
119-
<PublishAot>True</PublishAot>
119+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
120+
<IsAotCompatible>True</IsAotCompatible>
120121
</PropertyGroup>
121122

122-
<PropertyGroup Condition="'$(TargetFramework)' != 'net2.0-client'
123-
and '$(TargetFramework)' != 'net3.0-client' and
124-
('$(ImportAsync)' == 'True'
125-
or ('$(TargetFramework)' != 'net3.5-client'
126-
and '$(TargetFramework)' != 'net4.0-client'))">
123+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard1.0'))
124+
or ('$(ImportAsync)' == 'True'
125+
and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net3.5-client')))">
127126
<DefineConstants>$(DefineConstants);HAS_TASK</DefineConstants>
128127
</PropertyGroup>
128+
129+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'uap'))
130+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0-windows10.0.17763.0'))">
131+
<DefineConstants>$(DefineConstants);HAS_WINRT</DefineConstants>
132+
</PropertyGroup>
129133

130-
<PropertyGroup Condition="'$(TargetFramework)' == 'net2.0-client'
131-
or '$(TargetFramework)' == 'net3.0-client'
132-
or '$(TargetFramework)' == 'net3.5-client'
133-
or '$(TargetFramework)' == 'net4.0-client'
134-
or '$(TargetFramework)' == 'net4.5'
135-
or '$(TargetFramework)' == 'net4.6.1'
136-
or '$(TargetFramework)' == 'net4.8'
137-
or '$(TargetFramework)' == 'net6.0-windows10.0.17763.0'
138-
or '$(TargetFramework)' == 'net8.0-windows10.0.17763.0'">
134+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net1.1'))
135+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0-windows'))">
139136
<DefineConstants>$(DefineConstants);HAS_IMAGING</DefineConstants>
140137
</PropertyGroup>
141138

142-
<PropertyGroup Condition="'$(TargetFramework)' != 'net2.0-client'
143-
and '$(TargetFramework)' != 'net3.0-client'
144-
and '$(TargetFramework)' != 'net3.5-client'
145-
and '$(TargetFramework)' != 'net4.0-client'
146-
and '$(TargetFramework)' != 'net4.5'
147-
and '$(TargetFramework)' != 'net4.6.1'
148-
and '$(TargetFramework)' != 'netstandard1.3'
149-
and '$(TargetFramework)' != 'netcore5.0'
150-
and '$(TargetFramework)' != 'uap10.0'">
139+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net4.7'))
140+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp1.0'))
141+
or (!($([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework')
142+
and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.0')))">
151143
<DefineConstants>$(DefineConstants);HAS_VALUETUPLE</DefineConstants>
152144
</PropertyGroup>
153145

154-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'
155-
or '$(TargetFramework)' == 'net6.0-windows10.0.17763.0'
156-
or '$(TargetFramework)' == 'net8.0'
157-
or '$(TargetFramework)' == 'net8.0-windows10.0.17763.0'
158-
or '$(TargetFramework)' == 'netcoreapp3.1'
159-
or '$(TargetFramework)' == 'netstandard2.1'
160-
or '$(TargetFramework)' == 'uap10.0.15138.0'">
146+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.1'))
147+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'uap10.0.15138.0'))
148+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.1'))">
161149
<DefineConstants>$(DefineConstants);HAS_FULLSTRING</DefineConstants>
162150
</PropertyGroup>
163151

164-
<PropertyGroup Condition="'$(TargetFramework)' != 'net2.0-client'
165-
and '$(TargetFramework)' != 'net3.0-client'
166-
and '$(TargetFramework)' != 'net3.5-client'
167-
and '$(TargetFramework)' != 'net4.0-client'
168-
and '$(TargetFramework)' != 'net4.5'
169-
and '$(TargetFramework)' != 'net4.6.1'
170-
and '$(TargetFramework)' != 'netcore5.0'
171-
and '$(TargetFramework)' != 'uap10.0'">
172-
<DefineConstants>$(DefineConstants);HAS_RUNTIMEINFORMATION</DefineConstants>
173-
</PropertyGroup>
174-
175-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'
176-
or '$(TargetFramework)' == 'net6.0-windows10.0.17763.0'
177-
or '$(TargetFramework)' == 'net8.0'
178-
or '$(TargetFramework)' == 'net8.0-windows10.0.17763.0'
179-
or '$(TargetFramework)' == 'netcoreapp3.1'
180-
or '$(TargetFramework)' == 'netstandard2.1'">
152+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp2.1'))
153+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.1'))">
181154
<DefineConstants>$(DefineConstants);HAS_BUFFERS</DefineConstants>
182155
<PolySharpIncludeGeneratedTypes>$(PolySharpIncludeGeneratedTypes);System.Runtime.CompilerServices.CollectionBuilderAttribute</PolySharpIncludeGeneratedTypes>
183156
</PropertyGroup>
184157

185-
<PropertyGroup Condition="'$(TargetFramework)' != 'netcore5.0'
186-
and '$(TargetFramework)' != 'netcoreapp1.0'
187-
and '$(TargetFramework)' != 'netcoreapp1.1'
188-
and '$(TargetFramework)' != 'netstandard1.3'
189-
and '$(TargetFramework)' != 'uap10.0'">
158+
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net1.1'))
159+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp1.0'))
160+
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netstandard2.0'))">
190161
<DefineConstants>$(DefineConstants);HAS_PROCESS;HAS_SERIALIZATION</DefineConstants>
191162
</PropertyGroup>
192163

AdvancedSharpAdbClient/DeviceCommands/DeviceClient.Async.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public async Task<string> DumpScreenStringAsync(CancellationToken cancellationTo
5959
return null;
6060
}
6161

62-
#if WINDOWS_UWP || WINDOWS10_0_17763_0_OR_GREATER
62+
#if HAS_WINRT
6363
/// <summary>
6464
/// Gets the current device screen snapshot asynchronously.
6565
/// </summary>
@@ -362,7 +362,7 @@ static IEnumerable<Element> FindElements(IAdbClient client, DeviceData device, X
362362
return [];
363363
}
364364

365-
#if NETCOREAPP3_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
365+
#if COMP_NETSTANDARD2_1
366366
/// <summary>
367367
/// Gets elements by xpath asynchronously. You can specify the waiting time in timeout.
368368
/// </summary>

AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public string DumpScreenString()
9090
return null;
9191
}
9292

93-
#if WINDOWS_UWP || WINDOWS10_0_17763_0_OR_GREATER
93+
#if HAS_WINRT
9494
/// <summary>
9595
/// Gets the current device screen snapshot.
9696
/// </summary>

AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public static async Task<List<FileStatistics>> GetDirectoryListingAsync(this IAd
264264
return await service.GetDirectoryListingAsync(remotePath, cancellationToken).ConfigureAwait(false);
265265
}
266266

267-
#if NETCOREAPP3_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
267+
#if COMP_NETSTANDARD2_1
268268
/// <summary>
269269
/// Asynchronously lists the contents of a directory on the device.
270270
/// </summary>

AdvancedSharpAdbClient/DeviceCommands/Models/Element.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static IEnumerable<Element> FindElements(IAdbClient client, DeviceData device, X
8383
Children = FindElements(client, device, xmlNode);
8484
}
8585

86-
#if WINDOWS_UWP || WINDOWS10_0_17763_0_OR_GREATER
86+
#if HAS_WINRT
8787
/// <summary>
8888
/// Initializes a new instance of the <see cref="Element"/> class.
8989
/// </summary>
@@ -212,7 +212,7 @@ static IEnumerable<Element> FindElements(IAdbClient client, DeviceData device, W
212212
public static Element? FromXmlNode(IAdbClient client, DeviceData device, XmlNode? xmlNode) =>
213213
xmlNode?.Attributes?["bounds"] != null ? new Element(client, device, xmlNode) : null;
214214

215-
#if WINDOWS_UWP || WINDOWS10_0_17763_0_OR_GREATER
215+
#if HAS_WINRT
216216
/// <summary>
217217
/// Creates a new <see cref='Element'/> with the specified <see cref="Windows.Data.Xml.Dom.IXmlNode"/>.
218218
/// </summary>

AdvancedSharpAdbClient/DeviceCommands/Models/VersionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public readonly bool TryAsVersion(out Version? version)
6464
return true;
6565
}
6666

67-
#if WINDOWS_UWP || WINDOWS10_0_17763_0_OR_GREATER
67+
#if HAS_WINRT
6868
/// <summary>
6969
/// Try to parse the <see cref="VersionName"/> into a <see cref="PackageVersion"/> object.
7070
/// </summary>

AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ protected virtual async Task<string> SyncPackageToDeviceAsync(string localFilePa
579579

580580
using (ISyncService sync = SyncServiceFactory(AdbClient, Device))
581581
{
582-
#if NETCOREAPP3_0_OR_GREATER
582+
#if COMP_NETSTANDARD2_1
583583
await
584584
#endif
585585
using Stream stream = await GetFileStreamAsync(localFilePath, cancellationToken).ConfigureAwait(false);

AdvancedSharpAdbClient/DeviceMonitor.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected virtual async Task DisposeAsyncCore()
9191
disposed = true;
9292
}
9393

94-
#if NETCOREAPP3_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
94+
#if COMP_NETSTANDARD2_1
9595
/// <inheritdoc/>
9696
async ValueTask IAsyncDisposable.DisposeAsync()
9797
{

0 commit comments

Comments
 (0)