无法安装 playwright:无法使用 Playwright 找到项目。确保项目或解决方案存在于
Cannot install playwright: Couldn't find project using Playwright. Ensure a project or a solution exists in
我正在尝试在我的部署目标机器上安装 playwright,以便 运行 UI 测试。
# Install the CLI once.
dotnet tool install --global Microsoft.Playwright.CLI
playwright install
然而,当使用包括 playwright 安装在内的 playwright CLI 时,我得到:
Couldn't find project using Playwright. Ensure a project or a solution
exists in C:\users\myuser, or provide another path using -p.
如何在虚拟机上安装 playwright?
编辑:
遗憾的是,playwright 的 .NET nuget 包设计得不是很好。虽然 API 很棒,但部署却是噩梦。
不仅您无法在部署服务器上使用 CLI 安装浏览器,而且该软件包还会为您的项目以及所有引用它的项目增加 3 倍的 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-project
您还可以使用代码安装浏览器:
using Microsoft.Playwright;
var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" });
更多详情:https://www.meziantou.net/distributing-applications-that-depend-on-microsoft-playwright.htm
我正在尝试在我的部署目标机器上安装 playwright,以便 运行 UI 测试。
# Install the CLI once.
dotnet tool install --global Microsoft.Playwright.CLI
playwright install
然而,当使用包括 playwright 安装在内的 playwright CLI 时,我得到:
Couldn't find project using Playwright. Ensure a project or a solution exists in C:\users\myuser, or provide another path using -p.
如何在虚拟机上安装 playwright?
编辑:
遗憾的是,playwright 的 .NET nuget 包设计得不是很好。虽然 API 很棒,但部署却是噩梦。
不仅您无法在部署服务器上使用 CLI 安装浏览器,而且该软件包还会为您的项目以及所有引用它的项目增加 3 倍的 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-project
您还可以使用代码安装浏览器:
using Microsoft.Playwright;
var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" });
更多详情:https://www.meziantou.net/distributing-applications-that-depend-on-microsoft-playwright.htm