-
Notifications
You must be signed in to change notification settings - Fork 324
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
dotnet test for multi target net461 and netcoreapp3.1 success in windows but fail in Ubuntu 20.04 with error: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel #2469
Comments
I tried to reproduce and did not see the issue. Is there anything more to how you build / run the tests? |
Can you try to run test for this project |
Also, I run Click to expand Server stack trace!
Note: I checked this issue, but it is not relevant. |
I can see the same thing now. I would go with the workaround that you found. I couldn't think of any other way to solve this right now. |
What is the role of |
That assembly holds all the common types. On windows it grabs it from the SDK where we ship testhost.exe, but on Linux that does not work for some reason. |
I installed Xunit test success mono path/to/xunit.console.exe path/to/net461/test.dll # net461 working |
@nohwnd It was requested by @bradwilson, the author of Xunit, here
This package is used also by netcoreapp3.1 but it's loaded during netcoreapp3.1 build but it's not loaded during net461 build.
I noticed that the package has no project reference and it's not maintained since 2017, but the package is included in netcoreapp3.1 as version 16.6.1. Suggested solution |
When tests run locally from within VS, we use net472 so that TestDriven can run them quickly. In CI, we use net5, which requires Microsoft.TestPlatform.ObjectModel (see microsoft/vstest#2469 (comment))
When tests run locally from within VS, we use net472 so that TestDriven can run them quickly. In CI, we use net5, which requires Microsoft.TestPlatform.ObjectModel (see microsoft/vstest#2469 (comment))
…ception: Could not load type of field 'Xunit.Runner.VisualStudio.VsExecutionSink:recorder' (4) See microsoft/vstest#2469
Turns out xunit _can_ run tests on Mono, you just have to install an additional package to work around a vstest bug. See microsoft/vstest#2469
Turns out xunit _can_ run tests on Mono, you just have to install an additional package to work around a vstest bug. See microsoft/vstest#2469
@nohwnd I know you closed this as "Won't Fix", but this continues to be a sporadic problem on non-Windows machines trying to run
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1" />
</ItemGroup>
</Project>
using Xunit;
public class UnitTest1
{
[Fact]
public void Test1()
{
}
} Result: Adding a references to I've seen evidence through web searches that this happens to people using xUnit.net, NUnit, and MSTest. This leads me to believe that If the decision remains to leave this as "won't fix", then I'm considering adding Can you provide guidance on what the best way is for me to fix this for xUnit.net users in the safest possible way? |
After mulling it over last night, and doing some testing w/rt to version mismatches (no issues I could uncover), I've decided to add the dependency to https://xunit.net/releases/visualstudio/2.5.2-pre.10 All that said? Please, still, fix this bug. |
I've been meaning to respond here yesterday, but was too exhausted when I got to it in the evening. The reason why I did not want to fix this is because Microsoft.NET.Test.Sdk was designed to do nothing on a .NET Framework project. The .NET Framework project test runner is shipped with vstest.console (e.g. in dotnet sdk, or VS). Adding a dependency to Test.SDK that is specifically for .NET Framework, would make the package even more confusing, especially when on Windows ObjectModel is picked up from the vstest.console folder. For me the ideal fix would be to make the Test.SDK package work the same for .net framework as it works for .net, so it would ship testhost and the dependencies into the bin folder, and pick it up from there. For the problem, I can see it reproduces with xunit when appdomains are enabled, but not when they are disabled. ( |
@nohwnd Why does this work on Windows and not Linux? Are you secretly hooking something on behalf of the adapter in a way that doesn't work on Mono? |
I don't know. I've seen mono being more picky about the dlls that .net framework, but I cannot pinpoint it. I've tried running the same thing on linux (wsl) through vstest.console.exe to make sure we have the dlls in all the same places, and I get the same error as when using dotnet test. There are no fusion logs as far as I know on mono, so I am not sure how to progress. |
@nohwnd Can you point where in the code you determine the location of the testhost assembly? The link you pointed out just shows the resolution logic, but not how you constructed the list of folders to resolve with. |
https://github.com/microsoft/testfx/blob/main/src/Adapter/MSTestAdapter.PlatformServices/Services/TestSourceHost.cs#L357 It happens here, when the resolver is setup. It adds the directory of the host. |
I shipped 2.5.3 yesterday with the NuGet package dependency against If that blows up in unexpected ways, I'll consider pulling it back out and replacing it with this assembly resolver. We already do assembly resolution for the test adapter path, which I suspect was/is only necessary inside Visual Studio (as |
to try and work around microsoft/vstest#2469
to try and work around microsoft/vstest#2469
Environment
VS code
Version: 1.46.1
OS: Windows_NT x64 10.0.19041
Working in WSL 2 environment (Ubuntu 20.04, Mono is installed)
Steps to reproduce
A multi-target sdk-style Xunit test project
Package reference:
I followed the instructions Getting Started with xUnit.net Multi-targeting with non-Windows OSes
The test success locally in windows 10 x64 using vs code:
When running the test remotly in WSL 2 environment it fail for net461 with error:
If I add the next reference, test success
Should I add reference to
Microsoft.TestPlatform.ObjectModel
when runing in Linux environment in net461?What the role of this package?
The text was updated successfully, but these errors were encountered: