将 Selenium.PhantomJS.WebDriver 与 .Net Core 一起使用

问题描述 投票:0回答:1

NuGet 包 Selenium.PhantomJS.WebDriver,在构建项目时,它将 PhantomJS.exe 复制到 bin 文件夹。与经典的 .Net 配合使用效果非常好。

问题是对于 .NetCore 这不起作用。我可以直接将文件添加到解决方案中,指定为 copyOnBuild 但我想避免它。有什么建议吗?

谢谢。

c# selenium-webdriver phantomjs .net-core
1个回答
0
投票

我想到了两种解决方法;

如果您有机会使用像CopyLocalLockFileAssemblies这样的自定义工具,您可以在.csproj中尝试以下

<PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

第二个选项:

xcopy "$(SolutionDir)packages\Selenium.PhantomJS.WebDriver.{version}\tools\phantomjs.exe" "$(TargetDir)"

您可以将此命令放在 postbuild 中。我没有尝试过,但是这些可能有用。

© www.soinside.com 2019 - 2024. All rights reserved.