Reputation: 125
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!
Upvotes: 5
Views: 1426
Reputation: 487
I ran into the same issue and it was because the test project referenced another project that had the xunit.extensibility.core as a dependency. Reworking this so only the top-level test project had references to any xunit assemblies fixed it.
Upvotes: 0
Reputation: 1
I also had the same problem, using .net 8, it happens that I have a console type project and the Xunit project inside the same console project folder, there are many conflicts and one of them is not recognizing the installed Xunit package, the solution was to create the Xunit project one level above the console project folder.
Example of directories:
OK:
solutionFolder-->consoleAppFolder-->Console.csproj
solutionFolder-->testsFolder-->Console.Tests.csproj
KO:
solutionFolder-->consoleAppFolder-->Console.csproj
solutionFolder-->consoleAppFolder-->Console.Tests.csproj
Upvotes: 0
Reputation: 125
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!
Upvotes: 4