diff --git a/.github/workflows/nuget-package-tests.yml b/.github/workflows/nuget-package-tests.yml
new file mode 100644
index 00000000..49121e9c
--- /dev/null
+++ b/.github/workflows/nuget-package-tests.yml
@@ -0,0 +1,45 @@
+name: Tests Nuget Packages
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ test-nuget-packages:
+ name: Nuget Tests on ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [windows-latest, ubuntu-latest, macos-latest]
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET Core (On Mac)
+ if: ${{ matrix.os == 'macos-latest' }}
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.100
+ env:
+ DOTNET_INSTALL_DIR: /users/runner/alternate/dotnet
+ - name: Setup .NET Core (Not on mac)
+ if: ${{ matrix.os != 'macos-latest' }}
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.100
+ - name: Build Project
+ run: dotnet build ./src/PlaywrightSharp/PlaywrightSharp.csproj -c Debug
+ - name: Delete browsers on Mac
+ if: matrix.os == 'macos-latest'
+ run: rm -r ~/Library/Caches/ms-playwright
+ - name: Delete browsers on Linux
+ if: ${{ matrix.os == 'ubuntu-latest' }}
+ run: rm -r ~/.cache/ms-playwright
+ - name: Delete browsers on windows
+ if: matrix.os == 'windows-latest'
+ run: Remove-Item -path $env:USERPROFILE\AppData\Local\ms-playwright -recurse
+ - name: Run Tests
+ run: dotnet test ./src/PlaywrightSharp.LocalNugetTest/PlaywrightSharp.LocalNugetTest.csproj
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 60823d8b..10eede90 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -40,15 +40,19 @@ jobs:
if: ${{ matrix.os != 'ubuntu-latest' }}
env:
PRODUCT: ${{ matrix.product }}
- run: dotnet test ./src/PlaywrightSharp.Tests/PlaywrightSharp.Tests.csproj -c Debug -f netcoreapp3.1 --logger "trx;LogFileName=TestResults.xml"
+ run: |
+ dotnet build ./src/PlaywrightSharp/PlaywrightSharp.csproj -c Debug
+ dotnet test ./src/PlaywrightSharp.Tests/PlaywrightSharp.Tests.csproj -c Debug -f netcoreapp3.1 --logger "trx;LogFileName=TestResults.xml"
- name: Run tests (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
PRODUCT: ${{ matrix.product }}
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && dotnet test ./src/PlaywrightSharp.Tests/PlaywrightSharp.Tests.csproj -c Debug -f netcoreapp3.1 --logger \"trx;LogFileName=TestResults.xml\""
+ run: |
+ dotnet build ./src/PlaywrightSharp/PlaywrightSharp.csproj -c Debug
+ xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && dotnet test ./src/PlaywrightSharp.Tests/PlaywrightSharp.Tests.csproj -c Debug -f netcoreapp3.1 --logger \"trx;LogFileName=TestResults.xml\""
- name: Test results
uses: actions/upload-artifact@v1
if: always()
with:
name: TestResult.xml
- path: ./src/PlaywrightSharp.Tests/TestResults/TestResults.xml
+ path: ./src/PlaywrightSharp.Tests/TestResults/TestResults.xml
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index bf6b6fb9..1f9cb694 100644
--- a/.gitignore
+++ b/.gitignore
@@ -351,3 +351,4 @@ MigrationBackup/
.idea
src/PlaywrightSharp.sln.DotSettings
src/PlaywrightSharp/Drivers
+src/PlaywrightSharp/runtimes
diff --git a/src/Common/PackageInfo.props b/src/Common/PackageInfo.props
index f96e97b9..a88fd9d9 100644
--- a/src/Common/PackageInfo.props
+++ b/src/Common/PackageInfo.props
@@ -2,11 +2,11 @@
true
- 0.152.0
+ 0.162.0
+ $(AssemblyVersion)-alpha
0.162.1
- $(PackageVersion)
- $(PackageVersion)
- $(PackageVersion)
+ $(AssemblyVersion)
+ $(AssemblyVersion)
Darío Kondratiuk
Darío Kondratiuk
https://github.com/microsoft/playwright-sharp
diff --git a/src/PlaywrightSharp.LocalNugetTest/NuGet.Config b/src/PlaywrightSharp.LocalNugetTest/NuGet.Config
new file mode 100644
index 00000000..f7ec3bda
--- /dev/null
+++ b/src/PlaywrightSharp.LocalNugetTest/NuGet.Config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/src/PlaywrightSharp.LocalNugetTest/NugetTests.cs b/src/PlaywrightSharp.LocalNugetTest/NugetTests.cs
new file mode 100644
index 00000000..3bf67a58
--- /dev/null
+++ b/src/PlaywrightSharp.LocalNugetTest/NugetTests.cs
@@ -0,0 +1,23 @@
+using System;
+using System.IO;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace PlaywrightSharp.LocalNugetTest
+{
+ public class NugetTests
+ {
+ [Fact]
+ public async Task ShouldWork()
+ {
+ using var playwright = await Playwright.CreateAsync();
+ await using var browser = await playwright.Chromium.LaunchAsync();
+
+ var page = await browser.NewPageAsync();
+ Console.WriteLine("Navigating google");
+ await page.GoToAsync("http://www.google.com");
+
+ Assert.Contains("Google", await page.GetTitleAsync());
+ }
+ }
+}
diff --git a/src/PlaywrightSharp.LocalNugetTest/PlaywrightSharp.LocalNugetTest.csproj b/src/PlaywrightSharp.LocalNugetTest/PlaywrightSharp.LocalNugetTest.csproj
new file mode 100644
index 00000000..744ad539
--- /dev/null
+++ b/src/PlaywrightSharp.LocalNugetTest/PlaywrightSharp.LocalNugetTest.csproj
@@ -0,0 +1,19 @@
+
+
+
+ false
+ true
+ 8.0
+ 0.0.0
+ netcoreapp3.1
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
diff --git a/src/PlaywrightSharp.LocalNugetTest/PlaywrightSharp.LocalNugetTest.sln b/src/PlaywrightSharp.LocalNugetTest/PlaywrightSharp.LocalNugetTest.sln
new file mode 100644
index 00000000..b6555e37
--- /dev/null
+++ b/src/PlaywrightSharp.LocalNugetTest/PlaywrightSharp.LocalNugetTest.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlaywrightSharp.LocalNugetTest", "PlaywrightSharp.LocalNugetTest.csproj", "{A4AEC544-D521-4CD4-9A8F-F6926DEFC233}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4611591F-E17F-4601-89AC-F4D9BE665940}"
+ ProjectSection(SolutionItems) = preProject
+ NuGet.Config = NuGet.Config
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A4AEC544-D521-4CD4-9A8F-F6926DEFC233}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A4AEC544-D521-4CD4-9A8F-F6926DEFC233}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A4AEC544-D521-4CD4-9A8F-F6926DEFC233}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A4AEC544-D521-4CD4-9A8F-F6926DEFC233}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/src/PlaywrightSharp.Tests/BaseTests/PlaywrightSharpLoader.cs b/src/PlaywrightSharp.Tests/BaseTests/PlaywrightSharpLoader.cs
index 6f5a179f..7120be95 100644
--- a/src/PlaywrightSharp.Tests/BaseTests/PlaywrightSharpLoader.cs
+++ b/src/PlaywrightSharp.Tests/BaseTests/PlaywrightSharpLoader.cs
@@ -14,15 +14,13 @@ namespace PlaywrightSharp.Tests.BaseTests
internal static async Task SetupAsync()
{
- var downloaderTask = PlaywrightSharp.Playwright.InstallAsync();
-
Server = SimpleServer.Create(TestConstants.Port, TestUtils.FindParentDirectory("PlaywrightSharp.TestServer"));
HttpsServer = SimpleServer.CreateHttps(TestConstants.HttpsPort, TestUtils.FindParentDirectory("PlaywrightSharp.TestServer"));
var serverStart = Server.StartAsync();
var httpsServerStart = HttpsServer.StartAsync();
- await Task.WhenAll(downloaderTask, serverStart, httpsServerStart);
+ await Task.WhenAll(serverStart, httpsServerStart);
}
internal static Task TeardownAsync() => Task.WhenAll(Server.StopAsync(), HttpsServer.StopAsync());
diff --git a/src/PlaywrightSharp.sln b/src/PlaywrightSharp.sln
index 5491f811..00ddabe6 100644
--- a/src/PlaywrightSharp.sln
+++ b/src/PlaywrightSharp.sln
@@ -24,12 +24,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlaywrightSharp.Demo", "Pla
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{5C6D57B1-C82A-48D6-9EBD-73B712CAE476}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiChecker", "tools\ApiChecker\ApiChecker.csproj", "{9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlaywrightSharpTool", "tools\PlaywrightSharpTool\PlaywrightSharpTool.csproj", "{795BA2A6-D983-4D96-B817-6921A145AB56}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DriverDownloader", "tools\DriverDownloader\DriverDownloader.csproj", "{27C6BCBD-94DC-4D1F-8F61-85DD3258A8EB}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiChecker", "tools\ApiChecker\ApiChecker.csproj", "{307DF999-0B02-40C9-971F-7BA5203DBE61}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -52,10 +52,6 @@ Global
{FB3348E3-9759-4B90-9C8C-391F44AD5F8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB3348E3-9759-4B90-9C8C-391F44AD5F8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB3348E3-9759-4B90-9C8C-391F44AD5F8F}.Release|Any CPU.Build.0 = Release|Any CPU
- {9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Release|Any CPU.Build.0 = Release|Any CPU
{795BA2A6-D983-4D96-B817-6921A145AB56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{795BA2A6-D983-4D96-B817-6921A145AB56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{795BA2A6-D983-4D96-B817-6921A145AB56}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -63,15 +59,19 @@ Global
{27C6BCBD-94DC-4D1F-8F61-85DD3258A8EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27C6BCBD-94DC-4D1F-8F61-85DD3258A8EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27C6BCBD-94DC-4D1F-8F61-85DD3258A8EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {307DF999-0B02-40C9-971F-7BA5203DBE61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {307DF999-0B02-40C9-971F-7BA5203DBE61}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {307DF999-0B02-40C9-971F-7BA5203DBE61}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {307DF999-0B02-40C9-971F-7BA5203DBE61}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A907B324-4541-4FAF-8CAE-D0B512B4BC36} = {D250D790-5A30-4C38-8F60-50FA96DB4E67}
- {9430DBAB-C5E3-4D37-84B2-EF86566D5AAA} = {5C6D57B1-C82A-48D6-9EBD-73B712CAE476}
{795BA2A6-D983-4D96-B817-6921A145AB56} = {5C6D57B1-C82A-48D6-9EBD-73B712CAE476}
{27C6BCBD-94DC-4D1F-8F61-85DD3258A8EB} = {5C6D57B1-C82A-48D6-9EBD-73B712CAE476}
+ {307DF999-0B02-40C9-971F-7BA5203DBE61} = {5C6D57B1-C82A-48D6-9EBD-73B712CAE476}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D6EDE73-B005-4ABC-BCF8-BB3C154497EC}
diff --git a/src/PlaywrightSharp/Playwright.cs b/src/PlaywrightSharp/Playwright.cs
index 45e2ba41..e09f8f51 100644
--- a/src/PlaywrightSharp/Playwright.cs
+++ b/src/PlaywrightSharp/Playwright.cs
@@ -92,7 +92,6 @@ namespace PlaywrightSharp
///
/// Logger.
/// Task scheduler for long running tasks.
- /// Drivers location. Defaults to the PlaywrightSharp assembly path.
/// Playwright driver path. If not set needs to be used.
/// Specify a shared folder that playwright will use to download browsers and to look for browsers when launching browser instances.
/// It is a shortcut to the PLAYWRIGHT_BROWSERS_PATH environment variable.
@@ -104,7 +103,6 @@ namespace PlaywrightSharp
public static async Task CreateAsync(
ILoggerFactory loggerFactory = null,
TransportTaskScheduler scheduler = null,
- string driversLocationPath = null,
string driverExecutablePath = null,
string browsersPath = null,
string debug = null)
@@ -114,7 +112,7 @@ namespace PlaywrightSharp
Environment.SetEnvironmentVariable("DEBUG", debug);
}
- var connection = new Connection(loggerFactory, scheduler, driversLocationPath, driverExecutablePath, browsersPath);
+ var connection = new Connection(loggerFactory, scheduler, driverExecutablePath, browsersPath);
var playwright = await connection.WaitForObjectWithKnownName("Playwright").ConfigureAwait(false);
playwright.Connection = connection;
@@ -132,12 +130,6 @@ namespace PlaywrightSharp
public static Task InstallAsync(string browsersPath = null, string driverExecutablePath = null)
=> Connection.InstallAsync(driverExecutablePath, browsersPath);
- ///
- /// Creates a Playwright driver in the specified .
- ///
- /// Destination path.
- public static void InstallDriver(string path) => Connection.InstallDriver(path);
-
///
public void Dispose()
{
diff --git a/src/PlaywrightSharp/PlaywrightSharp.csproj b/src/PlaywrightSharp/PlaywrightSharp.csproj
index 64222081..6840d8fa 100644
--- a/src/PlaywrightSharp/PlaywrightSharp.csproj
+++ b/src/PlaywrightSharp/PlaywrightSharp.csproj
@@ -17,6 +17,7 @@
true
PlaywrightSharp
0.0.0
+ True
1701;1702;CS0067
@@ -24,6 +25,7 @@
+
<_Parameter1>PlaywrightSharp.Tests, PublicKey=$(AssemblyPublicKey)
@@ -32,32 +34,43 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
-
+
-
+
+
+ %(Filename)%(Extension)
+ PreserveNewest
+
+
+
+
+ %(Filename)%(Extension)
+ PreserveNewest
+
+
+
+
+ %(Filename)%(Extension)
+ PreserveNewest
+
+
+
\ No newline at end of file
diff --git a/src/PlaywrightSharp/Transport/Connection.cs b/src/PlaywrightSharp/Transport/Connection.cs
index 0a313d14..6208f894 100644
--- a/src/PlaywrightSharp/Transport/Connection.cs
+++ b/src/PlaywrightSharp/Transport/Connection.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
-using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.Json;
@@ -11,8 +10,6 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using PlaywrightSharp.Chromium;
using PlaywrightSharp.Helpers;
-using PlaywrightSharp.Helpers.Linux;
-using PlaywrightSharp.Transport;
using PlaywrightSharp.Transport.Channels;
using PlaywrightSharp.Transport.Converters;
using PlaywrightSharp.Transport.Protocol;
@@ -38,15 +35,9 @@ namespace PlaywrightSharp.Transport
public Connection(
ILoggerFactory loggerFactory,
TransportTaskScheduler scheduler,
- string driversLocationPath = null,
string driverExecutablePath = null,
string browsersPath = null)
{
- if (!string.IsNullOrEmpty(driverExecutablePath) && !string.IsNullOrEmpty(driversLocationPath))
- {
- throw new ArgumentException("Passing a driver executable path and a driver location path is not allowed");
- }
-
if (!string.IsNullOrEmpty(browsersPath))
{
Environment.SetEnvironmentVariable(BrowsersPathEnvironmentVariable, Path.GetFullPath(browsersPath));
@@ -58,7 +49,7 @@ namespace PlaywrightSharp.Transport
_rootObject = new ChannelOwnerBase(null, this, string.Empty);
- _playwrightServerProcess = GetProcess(driversLocationPath, driverExecutablePath);
+ _playwrightServerProcess = GetProcess(driverExecutablePath);
_playwrightServerProcess.StartInfo.Arguments = "run-driver";
_playwrightServerProcess.Start();
_playwrightServerProcess.Exited += (sender, e) => Close("Process exited");
@@ -101,45 +92,6 @@ namespace PlaywrightSharp.Transport
await tcs.Task.ConfigureAwait(false);
}
- internal static string InstallDriver(string driversPath)
- {
- if (string.IsNullOrEmpty(driversPath) && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(DriverPathEnvironmentVariable)))
- {
- driversPath = Environment.GetEnvironmentVariable(DriverPathEnvironmentVariable);
- }
-
- var assembly = typeof(Playwright).Assembly;
- string tempDirectory = new FileInfo(assembly.Location).Directory.FullName;
- driversPath ??= Path.Combine(tempDirectory, "playwright-sharp-drivers");
- string platform = "win32";
- string driver = "playwright-cli-win32.zip";
- string executableFile = "playwright-cli.exe";
-
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.OSArchitecture == Architecture.X64)
- {
- platform = "win32_x64";
- driver = "playwright-cli-win32_x64.zip";
- }
-
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
- {
- platform = "macos";
- driver = "playwright-cli-mac.zip";
- executableFile = "playwright-cli";
- }
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- platform = "linux";
- driver = "playwright-cli-linux.zip";
- executableFile = "playwright-cli";
- }
-
- string directory = Path.Combine(driversPath, assembly.GetName().Version.ToString(), platform);
- string file = Path.Combine(directory, driver);
- ExtractDriver(file, driver);
- return Path.Combine(directory, executableFile);
- }
-
internal void RemoveObject(string guid) => Objects.TryRemove(guid, out _);
internal Task SendMessageToServer(
@@ -265,12 +217,12 @@ namespace PlaywrightSharp.Transport
}
}
- private static Process GetProcess(string driversLocationPath = null, string driverExecutablePath = null)
+ private static Process GetProcess(string driverExecutablePath = null)
=> new Process
{
StartInfo =
{
- FileName = string.IsNullOrEmpty(driverExecutablePath) ? GetExecutablePath(driversLocationPath) : driverExecutablePath,
+ FileName = string.IsNullOrEmpty(driverExecutablePath) ? GetExecutablePath() : driverExecutablePath,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
@@ -279,41 +231,59 @@ namespace PlaywrightSharp.Transport
},
};
- private static string GetExecutablePath(string driversPath = null)
+ private static string GetExecutablePath()
{
- if (string.IsNullOrEmpty(driversPath) && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(DriverPathEnvironmentVariable)))
+ string driversPath;
+
+ if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(DriverPathEnvironmentVariable)))
{
driversPath = Environment.GetEnvironmentVariable(DriverPathEnvironmentVariable);
}
-
- return InstallDriver(driversPath);
- }
-
- private static void ExtractDriver(string file, string driver)
- {
- var directory = new FileInfo(file).Directory;
-
- if (!directory.Exists)
+ else
{
- Directory.CreateDirectory(directory.FullName);
+ var assembly = typeof(Playwright).Assembly;
+ driversPath = new FileInfo(assembly.Location).Directory.FullName;
+ }
- using (var resource = typeof(Playwright).Assembly.GetManifestResourceStream($"PlaywrightSharp.Drivers.{driver}"))
- using (var zipStream = new ZipArchive(resource))
- {
- zipStream.ExtractToDirectory(directory.FullName);
- }
+ string executableFile = Path.Combine(driversPath, "playwright-cli.exe");
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ executableFile = Path.Combine(driversPath, "playwright-cli");
+ }
+
+ if (!new FileInfo(executableFile).Exists)
+ {
+ string binPath = executableFile;
+
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- foreach (var executable in directory.GetFiles().Where(f => f.Name == "playwright-cli" || f.Name.Contains("ffmpeg")))
+ if (RuntimeInformation.OSArchitecture == Architecture.X64)
{
- if (LinuxSysCall.Chmod(executable.FullName, LinuxSysCall.ExecutableFilePermissions) != 0)
- {
- throw new PlaywrightSharpException($"Unable to chmod the driver ({Marshal.GetLastWin32Error()})");
- }
+ executableFile = Path.Combine(driversPath, "runtimes", "win-x64", "native", "playwright-cli.exe");
+ }
+ else
+ {
+ executableFile = Path.Combine(driversPath, "runtimes", "win-x86", "native", "playwright-cli.exe");
}
}
+
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ executableFile = Path.Combine(driversPath, "runtimes", "osx", "native", "playwright-cli");
+ }
+ else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ executableFile = Path.Combine(driversPath, "runtimes", "unix", "native", "playwright-cli");
+ }
+
+ if (!new FileInfo(executableFile).Exists)
+ {
+ throw new PlaywrightSharpException($"Driver not found neither at '{executableFile}', nor '{binPath}'");
+ }
}
+
+ return executableFile;
}
private void Transport_MessageReceived(object sender, MessageReceivedEventArgs e)
diff --git a/src/PlaywrightSharp/build/netstandard2.0/PlaywrightSharp.props b/src/PlaywrightSharp/build/netstandard2.0/PlaywrightSharp.props
new file mode 100644
index 00000000..821ed775
--- /dev/null
+++ b/src/PlaywrightSharp/build/netstandard2.0/PlaywrightSharp.props
@@ -0,0 +1,19 @@
+
+
+
+
+
+ PreserveNewest
+ false
+ %(Filename)%(Extension)
+
+
+ PreserveNewest
+ false
+ %(Filename)%(Extension)
+
+
+
\ No newline at end of file
diff --git a/src/PlaywrightSharp/build/netstandard2.0/PlaywrightSharp.targets b/src/PlaywrightSharp/build/netstandard2.0/PlaywrightSharp.targets
new file mode 100644
index 00000000..0a6e39cf
--- /dev/null
+++ b/src/PlaywrightSharp/build/netstandard2.0/PlaywrightSharp.targets
@@ -0,0 +1,16 @@
+
+
+
+
+
+ \native
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/PlaywrightSharp/Helpers/Linux/FileAccessPermissions.cs b/src/tools/DriverDownloader/Linux/FileAccessPermissions.cs
similarity index 94%
rename from src/PlaywrightSharp/Helpers/Linux/FileAccessPermissions.cs
rename to src/tools/DriverDownloader/Linux/FileAccessPermissions.cs
index 052c2295..35c7dc10 100644
--- a/src/PlaywrightSharp/Helpers/Linux/FileAccessPermissions.cs
+++ b/src/tools/DriverDownloader/Linux/FileAccessPermissions.cs
@@ -1,6 +1,6 @@
using System;
-namespace PlaywrightSharp.Helpers.Linux
+namespace DriverDownloader.Linux
{
[Flags]
internal enum FileAccessPermissions : uint
diff --git a/src/PlaywrightSharp/Helpers/Linux/LinuxSysCall.cs b/src/tools/DriverDownloader/Linux/LinuxSysCall.cs
similarity index 94%
rename from src/PlaywrightSharp/Helpers/Linux/LinuxSysCall.cs
rename to src/tools/DriverDownloader/Linux/LinuxSysCall.cs
index bd637669..b1b36f58 100644
--- a/src/PlaywrightSharp/Helpers/Linux/LinuxSysCall.cs
+++ b/src/tools/DriverDownloader/Linux/LinuxSysCall.cs
@@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
-namespace PlaywrightSharp.Helpers.Linux
+namespace DriverDownloader.Linux
{
internal static class LinuxSysCall
{
diff --git a/src/tools/DriverDownloader/Program.cs b/src/tools/DriverDownloader/Program.cs
index 8b10a267..59e90e97 100644
--- a/src/tools/DriverDownloader/Program.cs
+++ b/src/tools/DriverDownloader/Program.cs
@@ -1,13 +1,25 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.IO.Compression;
+using System.Linq;
using System.Net.Http;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
+using DriverDownloader.Linux;
namespace DriverDownloader
{
class Program
{
+ private static readonly (string Platform, string Runtime)[] _platforms = new[]
+ {
+ ("mac", "osx"),
+ ("linux", "unix"),
+ ("win32_x64", "win-x64"),
+ ("win32", "win-x86")
+ };
+
static async Task Main(string[] args)
{
if (args.Length < 2)
@@ -35,9 +47,9 @@ namespace DriverDownloader
versionFile.CreateText();
var tasks = new List();
- foreach (string platform in new[] { "mac", "linux", "win32_x64", "win32" })
+ foreach (var platform in _platforms)
{
- tasks.Add(DownloadDriverAsync(destinationDirectory, driverVersion, platform));
+ tasks.Add(DownloadDriverAsync(destinationDirectory, driverVersion, platform.Platform, platform.Runtime));
}
await Task.WhenAll(tasks);
@@ -48,7 +60,7 @@ namespace DriverDownloader
}
}
- private static async Task DownloadDriverAsync(DirectoryInfo destinationDirectory, string driverVersion, string platform)
+ private static async Task DownloadDriverAsync(DirectoryInfo destinationDirectory, string driverVersion, string platform, string runtime)
{
Console.WriteLine("Downloading driver for " + platform);
const string cdn = "https://playwright.azureedge.net/builds/cli";
@@ -61,8 +73,19 @@ namespace DriverDownloader
return;
}
- using var fs = new FileStream(Path.Combine(destinationDirectory.FullName, $"playwright-cli-{platform}.zip"), FileMode.CreateNew);
- await response.Content.CopyToAsync(fs);
+ var directory = new DirectoryInfo(Path.Combine(destinationDirectory.FullName, runtime));
+ new ZipArchive(await response.Content.ReadAsStreamAsync()).ExtractToDirectory(directory.FullName);
+
+ if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ foreach (var executable in directory.GetFiles().Where(f => f.Name == "playwright-cli" || f.Name.Contains("ffmpeg")))
+ {
+ if (LinuxSysCall.Chmod(executable.FullName, LinuxSysCall.ExecutableFilePermissions) != 0)
+ {
+ throw new Exception($"Unable to chmod the driver ({Marshal.GetLastWin32Error()})");
+ }
+ }
+ }
Console.WriteLine($"Driver for {platform} downloaded");
}
}
diff --git a/src/tools/PlaywrightSharpTool/Options/InstallAllOptions.cs b/src/tools/PlaywrightSharpTool/Options/InstallAllOptions.cs
deleted file mode 100644
index c3f9889b..00000000
--- a/src/tools/PlaywrightSharpTool/Options/InstallAllOptions.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using CommandLine;
-
-namespace PlaywrightSharpTool.Options
-{
- [Verb("install-all", HelpText = "Install the playwright driver and the required browsers. Pass --driverpath to specify the driver location and --browserpath to specify the location of the browsers.")]
- public class InstallAllOptions
- {
- [Option(Required = false, HelpText = "Browsers destination path. If not passed, the default shared location will be used.")]
- public string DriverPath { get; set; }
-
- [Option(Required = false, HelpText = "Driver destination path. If not passed, CWD will be used.")]
- public string BrowsersPath { get; set; }
- }
-}
diff --git a/src/tools/PlaywrightSharpTool/Options/InstallDriverOptions.cs b/src/tools/PlaywrightSharpTool/Options/InstallDriverOptions.cs
deleted file mode 100644
index 2a7cb9c8..00000000
--- a/src/tools/PlaywrightSharpTool/Options/InstallDriverOptions.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using CommandLine;
-
-namespace PlaywrightSharpTool.Options
-{
- [Verb("install-driver", HelpText = "Install the playwright driver. Pass --path to specify the driver location.")]
- public class InstallDriverOptions
- {
- [Option(Required = false, HelpText = "Driver destination path. If not passed, CWD will be used.")]
- public string Path { get; set; }
- }
-}
diff --git a/src/tools/PlaywrightSharpTool/Program.cs b/src/tools/PlaywrightSharpTool/Program.cs
index 930d8a81..5c4e3c8b 100644
--- a/src/tools/PlaywrightSharpTool/Program.cs
+++ b/src/tools/PlaywrightSharpTool/Program.cs
@@ -10,27 +10,11 @@ namespace PlaywrightSharpTool
{
static Task Main(string[] args)
{
- return Parser.Default.ParseArguments(args).MapResult(
+ return Parser.Default.ParseArguments(args).MapResult(
async (InstallBrowsersOptions opts) => await InstallAsync(opts),
- async (InstallDriverOptions opts) => await InstallDriverAsync(opts),
- async (InstallAllOptions opts) => await InstallAllDriverAsync(opts),
_ => Task.FromResult