xunit / visualstudio.xunit

VSTest runner for xUnit.net (for Visual Studio Test Explorer and dotnet test)
https://xunit.net/
Other
144 stars 81 forks source link

xUnit Tests for .NET 6 in ADO pipeline fail, Microsoft.TestPlatform.CommunicationUtilities from testhost.deps.json was not found #372

Closed iansul closed 7 months ago

iansul commented 1 year ago

I have a Test project that tests a Project that produces a NuGet package that targets net472 and net6.0. It properly tests both Net 4.7.2 and Net 6.0 locally, but when I try to run the tests in an ADO pipeline it fails to run the net6.0 target with the error:

Test run for /home/vsts/work/1/s/src/NodeServices/NodeServices/test/bin/Release/net6.0/Microsoft.DynamicContentServices.NodeServices.Test.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.5.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process for source(s) '/home/vsts/work/1/s/src/NodeServices/NodeServices/test/bin/Release/net6.0/Microsoft.DynamicContentServices.NodeServices.Test.dll' exited with error: Error:
  An assembly specified in the application dependencies manifest (testhost.deps.json) was not found:
    package: 'Microsoft.TestPlatform.CommunicationUtilities', version: '15.0.0.0'
    path: 'Microsoft.TestPlatform.CommunicationUtilities.dll'
. Please check the diagnostic logs for more information.

I can't figure out which diagnostic logs I should look in. And I can't find the "testhost.deps.json" file anywhere in my local build to see what's in it and maybe tell me where I could look for it in the ADO build to see if it's different.

The net4.7.2 target completes successfully:

Test run for /home/vsts/work/1/s/src/NodeServices/NodeServices/test/bin/Release/net472/Microsoft.DynamicContentServices.NodeServices.Test.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 17.5.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
info: Microsoft.DynamicContentServices.NodeServices[0]
      executesOnLoad: This is from .NET
Results File: /home/vsts/work/_temp/_fv-az163-991_2023-05-08_23_41_21.trx

Passed!  - Failed:     0, Passed:    15, Skipped:     0, Total:    15, Duration: 1 s - Microsoft.DynamicContentServices.NodeServices.Test.dll (net472)

Does this have anything to do with trying to run the pipeline on an ubuntu image? My pipeline doesn't specify a pool so it's getting the default from Azure Pipelines Pool which seems to be ubuntu.

Not sure if this is related but I'm also trying to capture code coverage with coverlet.

bradwilson commented 1 year ago

It's hard to know, given that it works locally for you (and me as well, just using dotnet new xunit and "downgrading" the generated project to .NET 6). If this didn't work, the .NET team would've in contact, since they use xUnit.net as well, and they're using Azure Pipelines as well (I see tons of their builds on GitHub PRs showing up with Azure Pipelines icons/links, like this one which has results on Azure Pipelines. Many of those are running on Linux.

I'm assuming the failing project you have is a closed source project. Is it possible to trim down to a repro that could be shared?

iansul commented 1 year ago

Thanks for the follow up @bradwilson I will see if I can get a minimal repro.

bradwilson commented 7 months ago

Closing for lack of response. Please open a new issue if this is still a problem. Thanks!