dllpathxunit.net-8.0

Trouble running xunit tests in .net8


I am currently updating a large application from .net 4.8 framework to .net 8. I've had many errors, but most I have been able to solve so far with some reasearch. This one has been stumping me a little bit, I think just due to lack of experience with dll issues and not fully understanding the problem.

In the new .net8 solution, many of the old tests cannot be run by visual studio because of this error: --- EXCEPTION #1/2 [RdFault] Message = “ Could not find/load any of the following assemblies: xunit.execution.dotnet.dll, reason: System.InvalidOperationException: Could not find/load any of the following assemblies: xunit.execution.dotnet.dll at Xunit.Xunit2Discoverer.GetExecutionAssemblyFileName(AppDomainSupport appDomainSupport, String basePath) in C:\Dev\xunit\xunit\src\xunit.runner.utility\Frameworks\v2\Xunit2Discoverer.cs:line 235 at Xunit.Xunit2Discoverer.GetXunitExecutionAssemblyPath(AppDomainSupport appDomainSupport, String assemblyFileName, Boolean verifyTestAssemblyExists) in C:\Dev\xunit\xunit\src\xunit.runner.utility\Frameworks\v2\Xunit2Discoverer.cs:line 265 at Xunit.Xunit2Discoverer..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyAssembliesOnDisk) in C:\Dev\xunit\xunit\src\xunit.runner.utility\Frameworks\v2\Xunit2Discoverer.cs:line 62 at Xunit.Xunit2..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyTestAssemblyExists)

At first I thought this could have been because the xunit packages I installed were at newer versions than the original project, but after fixing them nothing as changed. Then I realized the path is clearly wrong because I dont have a Dev folder in my C drive.

Could that be the problem? I have no idea how dlls work when nuget packages are downloaded. If the issue could be the path, how can I change that? I'm struggling to find online support for this problem in .net8 as I think its a newer issue.

Thank you everyone for any support & insight!


Solution

  • After a long time of investigating this question, what solved my problem was changing the output type of the affected projects from class library to console application. Hope this helps anyone having the same problem!