无法安装剧作家:无法使用剧作家找到项目。确保项目或解决方案存在于



为了运行UI测试,我正试图在部署目标机器上安装player。

# Install the CLI once.
dotnet tool install --global Microsoft.Playwright.CLI
playwright install

然而,当使用包括剧作家安装在内的剧作家CLI时,我得到:

找不到使用Playwright的项目。确保项目或解决方案存在于C:\users\myuser中,或者使用-p提供另一个路径。

如何在vm上安装player?

编辑:

不幸的是,用于剧作家的.NET nuget包设计得不太好。虽然API非常出色,但部署却是噩梦。

您不仅无法在部署服务器上使用CLI安装浏览器,而且该包还为您的项目以及所有引用它的项目添加了3x NodeJS运行时(200MB(。

阻止这些文件被发布是不容易的,并且每个构建的构建工件可以轻松地增长到1GB!

您无法配置NodeJS或剧作家本身的路径。

您可以在此处投票支持解决此问题:https://github.com/microsoft/playwright-dotnet/issues/1850

您需要在包含csproj的文件夹中执行playwright install,或者使用-p指定项目文件

# Create project
dotnet new console -n PlaywrightDemo
cd PlaywrightDemo
# Install dependencies, build project and download necessary browsers.
dotnet add package Microsoft.Playwright
dotnet build
playwright install

有关更多详细信息,请参阅文档:https://playwright.dev/dotnet/docs/intro#first-项目

您也可以使用以下代码安装浏览器:

using Microsoft.Playwright;
var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" });

更多详细信息:https://www.meziantou.net/distributing-applications-that-depend-on-microsoft-playwright.htm

为我解决的问题是。。在管道中构建解决方案之前,可以在管道中使用.net core的restore命令再次恢复剧作家包,并在构建管道后使用powershell安装剧作家驱动程序,如以下

选择类型FilePath

脚本路径:YourProjectName\bin\Debug\netcoreapp3.1\playwright.ps1

最新更新