playwright-dotnet icon indicating copy to clipboard operation
playwright-dotnet copied to clipboard

[BUG] Microsoft.Bcl.AsyncInterfaces is not a valid depenendency for .NET 8

Open anonhostpi opened this issue 1 year ago • 2 comments

System info

  • Playwright Version: v1.41.0
  • Operating System: Windows 11
  • Browser: All
  • Failing Environment: PowerShell 7 on .NET 8
  • Working Environment: Windows PowerShell (PowerShell 5)

Source code

  • [x] I provided exact source code that allows reproducing the issue locally.

Repro Method 1 (Import-Package module):

# Install-Module "Import-Package"; Import-Module "Import-Package"

[System.Runtime.InteropServices.RuntimeInformation, mscorlib]::FrameworkDescription
# .NET 8.0.0
Import-Package Microsoft.Playwright # or Import-Package Microsoft.Bcl.AsyncInterfaces

Repro Method 2 (PowerShell builtins):

[System.Runtime.InteropServices.RuntimeInformation, mscorlib]::FrameworkDescription
# .NET 8.0.0

# Install-Package Microsoft.Bcl.AsyncInterfaces
$pack = Get-Package Microsoft.Bcl.AsyncInterfaces
$pack_path = $pack.Source | Split-Path -Parent
$net8_dll = "$pack_path\lib\netstandard2.0\Microsoft.Bcl.AsyncInterfaces.dll"

Import-Module $net8_dll

Test file (self-contained) - Not Applicable

N/A - Environment is PowerShell and package dependency (Microsoft.Bcl.AsyncInterfaces) does not even load in .NET 8

Steps

  • Run PowerShell 7 on .NET 8
  • Run the above commands for either Repro Method 1 or Repro Method 2
  • To confirm that this is not the expected behavior, you can run the same in PowerShell 5 (Windows PowerShell), and it works fine.

Expected

Types load into the PowerShell session.

Actual

Import-Module: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxx'

From Microsoft.Bcl.AsyncInterfaces readme on Nuget.Org:

image

anonhostpi avatar Jan 18 '24 08:01 anonhostpi

Since we are targeting netstandard2.0 it seems reasonable to also depend on Microsoft.Bc.AsyncIntefaces as per their readme on nuget.org.

Would it be possible to provide us a self-contained reproduction? So far PowerShell wasn't a platform which we were targeting / testing.

mxschmitt avatar Feb 05 '24 11:02 mxschmitt

Not at the moment no. My dev environment is being upgraded. Also, I only use C# libraries and code in PowerShell.

Despite writing C# code for powershell for as long as I have, I have never actually built a C# standalone app/package. With Add-Type and PowerShell's access to the .NET type system, I have never had a need for it.

In short, I am completely unfamiliar with Visual Studio and the dotnet/msbuild utilities.

Not to say that I couldn't bridge that gap and work on a self-contained repro--it would just take some time. Though, I can't imagine it would be too difficult to do, since it should be just a matter of targeting .NET 8 and including your lib as dep in Visual Studio.

anonhostpi avatar Feb 06 '24 09:02 anonhostpi

I'll close it in the meantime, since we don't have a reproduction. We recommend the latest .NET LTS (8) and C# when using our library or following our getting-started guide using NUnit/MSTest test-runner bindings.

mxschmitt avatar Feb 26 '24 08:02 mxschmitt