Skip to content

Commit c5437fd

Browse files
Add support for .Net 4.6 and Standard 2.1 (#140)
Co-authored-by: Aliaksandr Rasolka <[email protected]>
1 parent 33844f8 commit c5437fd

File tree

6 files changed

+60
-21
lines changed

6 files changed

+60
-21
lines changed
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
4+
<TargetFrameworks>net46;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
65
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

98
<ItemGroup>
10-
<PackageReference Include="coverlet.msbuild" Version="3.1.0" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
12-
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
13-
<PackageReference Include="xunit" Version="2.4.1" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
9+
<PackageReference Include="coverlet.msbuild" Version="3.1.0"/>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0"/>
11+
<PackageReference Include="Selenium.WebDriver" Version="3.141.0"/>
12+
<PackageReference Include="xunit" Version="2.4.1"/>
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"/>
1514
</ItemGroup>
1615

1716
<ItemGroup>
18-
<ProjectReference Include="..\WebDriverManager\WebDriverManager.csproj" />
17+
<ProjectReference Include="..\WebDriverManager\WebDriverManager.csproj"/>
1918
</ItemGroup>
2019

2120
<ItemGroup>
22-
<None Remove="Assets\file.txt" />
21+
<None Remove="Assets\file.txt"/>
2322
<Content Include="Assets\file.txt">
2423
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2524
</Content>
26-
<None Remove="Assets\removable.zip" />
25+
<None Remove="Assets\removable.zip"/>
2726
<Content Include="Assets\removable.zip">
2827
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2928
</Content>
30-
<None Remove="Assets\unzipable.zip" />
29+
<None Remove="Assets\unzipable.zip"/>
3130
<Content Include="Assets\unzipable.zip">
3231
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3332
</Content>
3433
</ItemGroup>
3534

3635
<ItemGroup>
37-
<None Update="Assets\gzip.tar.gz">
38-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
39-
</None>
36+
<None Update="Assets\gzip.tar.gz">
37+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
38+
</None>
4039
</ItemGroup>
4140

41+
<PropertyGroup>
42+
<VSTestLogger>trx%3bLogFileName=Results$(TargetFramework).trx</VSTestLogger>
43+
</PropertyGroup>
4244
</Project>

WebDriverManager/DriverConfigs/Impl/ChromeConfig.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public virtual string GetUrl64()
3131

3232
private string GetUrl()
3333
{
34+
#if NETSTANDARD
3435
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
3536
{
3637
return $"{BaseVersionPatternUrl}chromedriver_mac64.zip";
@@ -40,13 +41,18 @@ private string GetUrl()
4041
{
4142
return $"{BaseVersionPatternUrl}chromedriver_linux64.zip";
4243
}
44+
#endif
4345

4446
return $"{BaseVersionPatternUrl}chromedriver_win32.zip";
4547
}
4648

4749
public virtual string GetBinaryName()
4850
{
51+
#if NETSTANDARD
4952
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
53+
#else
54+
var isWindows = true;
55+
#endif
5056
var suffix = isWindows ? ".exe" : string.Empty;
5157
return $"chromedriver{suffix}";
5258
}
@@ -84,6 +90,7 @@ public virtual string GetMatchingBrowserVersion()
8490

8591
private string GetRawBrowserVersion()
8692
{
93+
#if NETSTANDARD
8794
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
8895
{
8996
return RegistryHelper.GetInstalledBrowserVersionOsx("Google Chrome", "--version");
@@ -100,6 +107,9 @@ private string GetRawBrowserVersion()
100107
}
101108

102109
throw new PlatformNotSupportedException("Your operating system is not supported");
110+
#else
111+
return RegistryHelper.GetInstalledBrowserVersionWin("chrome.exe");
112+
#endif
103113
}
104114
}
105115
}

WebDriverManager/DriverConfigs/Impl/EdgeConfig.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,24 @@ public virtual string GetUrl32()
2323

2424
public virtual string GetUrl64()
2525
{
26+
#if NETSTANDARD
2627
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
2728
? $"{BaseVersionPatternUrl}edgedriver_mac64.zip"
2829
: $"{BaseVersionPatternUrl}edgedriver_win64.zip";
30+
#else
31+
return $"{BaseVersionPatternUrl}edgedriver_win64.zip";
32+
#endif
2933
}
3034

3135
public virtual string GetBinaryName()
3236
{
37+
#if NETSTANDARD
3338
return RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
3439
? "msedgedriver"
3540
: "msedgedriver.exe";
41+
#else
42+
return "msedgedriver.exe";
43+
#endif
3644
}
3745

3846
public virtual string GetLatestVersion()
@@ -60,6 +68,7 @@ public virtual string GetLatestVersion(string url)
6068

6169
public string GetMatchingBrowserVersion()
6270
{
71+
#if NETSTANDARD
6372
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
6473
{
6574
return RegistryHelper.GetInstalledBrowserVersionOsx("Microsoft Edge", "--version");
@@ -71,6 +80,9 @@ public string GetMatchingBrowserVersion()
7180
}
7281

7382
throw new PlatformNotSupportedException("Your operating system is not supported");
83+
#else
84+
return RegistryHelper.GetInstalledBrowserVersionWin("msedge.exe");
85+
#endif
7486
}
7587
}
7688
}

WebDriverManager/DriverConfigs/Impl/FirefoxConfig.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ public virtual string GetUrl64()
2828

2929
public virtual string GetBinaryName()
3030
{
31+
#if NETSTANDARD
3132
return "geckodriver" + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty);
33+
#else
34+
return "geckodriver.exe";
35+
#endif
3236
}
3337

3438
public virtual string GetLatestVersion()
@@ -54,14 +58,18 @@ public virtual string GetMatchingBrowserVersion()
5458

5559
private static string GetUrl(Architecture architecture)
5660
{
61+
#if NETSTANDARD
5762
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
5863
{
5964
return $"{DownloadUrl}macos.tar.gz";
6065
}
6166

6267
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
63-
? $"{DownloadUrl}linux{((int)architecture).ToString()}.tar.gz"
64-
: $"{DownloadUrl}win{((int)architecture).ToString()}.zip";
68+
? $"{DownloadUrl}linux{((int)architecture)}.tar.gz"
69+
: $"{DownloadUrl}win{((int)architecture)}.zip";
70+
#else
71+
return $"{DownloadUrl}win{(int)architecture}.zip";
72+
#endif
6573
}
6674
}
6775
}

WebDriverManager/Services/Impl/BinaryService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using ICSharpCode.SharpZipLib.GZip;
2+
using ICSharpCode.SharpZipLib.Tar;
23
using System;
34
using System.Diagnostics;
45
using System.IO;
56
using System.IO.Compression;
67
using System.Net;
78
using System.Runtime.InteropServices;
89
using System.Text;
9-
using ICSharpCode.SharpZipLib.Tar;
1010
using WebDriverManager.Helpers;
1111

1212
namespace WebDriverManager.Services.Impl
@@ -35,12 +35,14 @@ public string SetupBinary(string url, string zipDestination, string binDestinati
3535
UnZipTgz(zipDestination, binDestination);
3636
}
3737

38+
#if NETSTANDARD
3839
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
3940
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
4041
{
4142
var chmod = Process.Start("chmod", $"+x {binDestination}");
4243
chmod?.WaitForExit();
4344
}
45+
#endif
4446

4547
RemoveZip(zipDestination);
4648
return binDestination;

WebDriverManager/WebDriverManager.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
5+
<TargetFrameworks>netstandard2.0;netstandard2.1;net46</TargetFrameworks>
56
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
67
<PackageVersion>2.11.3</PackageVersion>
78
<Title>WebDriverManager.Net</Title>
89
<Description>Automatic Selenium WebDriver binaries management for .Net</Description>
910
<Copyright>© 2016-2021, Aliaksandr Rasolka. All Rights Reserved.</Copyright>
1011
<PackageProjectUrl>https://github.com/rosolko/WebDriverManager.Net</PackageProjectUrl>
11-
<PackageLicenseUrl>https://github.com/rosolko/WebDriverManager.Net/blob/master/LICENSE</PackageLicenseUrl>
12+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1213
<RepositoryUrl>https://github.com/rosolko/WebDriverManager.Net</RepositoryUrl>
1314
<RepositoryType>git</RepositoryType>
1415
<PackageTags>Selenium WebDriver ChromeDriver EdgeDriver InternetExplorerDriver MarionetteDriver OperaDriver PhantomJsDriver</PackageTags>
@@ -21,4 +22,8 @@
2122
<PackageReference Include="SharpZipLib" Version="1.3.2" />
2223
</ItemGroup>
2324

25+
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
26+
<Reference Include="System.IO.Compression" />
27+
</ItemGroup>
28+
2429
</Project>

0 commit comments

Comments
 (0)