Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformNotSupportException - System.DirectoryServices.*.dll seems not resolved to the correct platform when run with nunit-console 3.16.2 #1341

Closed
nickkfwong opened this issue May 4, 2023 · 1 comment

Comments

@nickkfwong
Copy link

nickkfwong commented May 4, 2023

Hello,
My test has a dependency on System.DirectoryServices.AccountManagement.dll.

When running the test on VS, the dll can be resolved to the correct platform-specific dll under .\bin\Debug\net6.0-windows\runtimes\win\lib\netcoreapp2.0\System.DirectoryServices.AccountManagement.dll

This basically is copied from this package path:
<nuget>\system.directoryservices.accountmanagement\5.0.0\runtimes\win\lib\netcoreapp2.0\

However, when run with nunit-console (3.16.2), eg:
<nuget>\packages\nunit.consolerunner\3.16.2\tools\nunit3-console.exe .\bin\Debug\net6.0-windows\sample.dll

The dll is resolved wrongly to (by looking through debug mode)
.\bin\Debug\net6.0-windows\System.DirectoryServices.AccountManagement.dll

And this dll actually is copied from this package path: (which is not framework dependent)
<nuget>\system.directoryservices.accountmanagement\5.0.0\lib\netstandard2.0\

Checking out other issues, the symptom seems exact to that of being reported in #1282.

So I tried 3.15.2 instead, and the test can pass.
Also dotnet test have no issue.

Would like to see if there is anything I can configure other than falling back to use 3.15.2?

Thanks for your advice.

A minimal project setup:

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
    <PackageReference Include="NUnit" Version="3.13.3" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
    <PackageReference Include="System.DirectoryServices.AccountManagement" Version="5.0.0" />
  </ItemGroup>

with a simple test

[Test]
        public void Test1()
        {
            var email = UserPrincipal.Current.EmailAddress; // throw here with nunit-console 3.16.2
            Assert.Pass();
        }
@OsirisTerje
Copy link
Member

You should fall back to 3.15.2. The bug you have hit will hopefully be fixed in 3.17. Dotnet test uses the adapter, which again uses a 3.15-prerelase version of the engine. embedded. Please also note that if you use the adapter you can't mix that with other engine packages. (Reading above, you don't have any console or engine packages, so that's fine). Also, there should be no reason to use the console if you're already using dotnet test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants