[BUG] Install script unable to find Microsoft.Playwright.dll

See original GitHub issue

Context:

  • Playwright Version: 1.21.0
  • Operating System: Windows
  • .NET version: NET 6
  • Browser: Chromium

Describe the bug

I am unable to run the install script. After adding the Microsoft.Playwright package to my project, I try to run the install script pwsh bin\Debug\net6.0\playwright.ps1 install, but I get the following error.

MethodInvocationException: {MY PROJECT FOLDER}\bin\Debug\net6.0\playwright.ps1:4
Line |
   4 |  [Reflection.Assembly]::LoadFile($PlaywrightFileName) | Out-Null
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "LoadFile" with "1" argument(s): "Could not load file or assembly
     | '{MY PROJECT FOLDER}\bin\Debug\net6.0\Microsoft.Playwright.dll'. The
     | system cannot find the file specified."

InvalidOperation: {MY PROJECT FOLDER}\bin\Debug\net6.0\playwright.ps1:5
Line |
   5 |  exit [Microsoft.Playwright.Program]::Main($args)
     |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Unable to find type [Microsoft.Playwright.Program].

Microsoft.Playwright.dll does not exist anywhere in my project’s bin folder.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
campersaucommented, Jun 7, 2022

@Ruud2000 that is the “new” behavior of .NET Core / .NET as it no longer copies all the dependency DLLs by default for library projects as it did for .NET Framework, or more generally where <HasRuntimeOutput> is false. See https://github.com/dotnet/sdk/blob/ee0504f6b4b95ff76a505cd236020a86c1f1fc63/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets#L23-L30 https://github.com/dotnet/sdk/blob/ad1ca90ad286288970a4ae1ec77e85848fef5a24/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L312-L331

So if you need the DLL in the output directory of a library project, set the property <HasRuntimeOutput>true</HasRuntimeOutput> in the project file or pass the property as argument when building via CLI /p:HasRuntimeOutput=true.

1reaction
DaveNatalieTripArccommented, Jun 7, 2022

@Ruud2000, you are correct, I am installing playwright in a library project. I was not aware of the <HasRuntieOutput> flag that @campersau mentioned.

Thanks for providing a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.net - Cannot install playwright: Couldn't find project using ...
Run from the Microsoft.Playwright.dll . This dll is in the NuGet package Microsoft.Playwright . This method calls the exe located in the ....
Read more >
How to use Run method of Microsoft.Playwright.Program ...
Use the Run method in Microsoft.Playwright package in your next Playwright-dotnet project with LambdaTest Automation Testing Advisor.
Read more >
Browsers
Each version of Playwright needs specific versions of browser binaries to operate. You will need to use the Playwright CLI to install these...
Read more >
ImportError: DLL load failed while importing _greenlet: The ...
I am not new to setting up python on windows, or with using playwright. This error barely exists on google ~3 relevant results....
Read more >
Distributing applications that depend on Microsoft.Playwright
In this post, I describe how to publish and distribute an application that rely on Microsoft.Playwright.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found