From 6fec5cf6ea39595f8478a09c887749d42ac4b89f Mon Sep 17 00:00:00 2001 From: Ilia K Date: Fri, 9 Aug 2024 15:16:38 +0200 Subject: [PATCH] Probe assemblies with .exe extension when loading from the test assembly's folder in TestAssemblyLoadContext --- .../Internal/TestAssemblyLoadContext.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/NUnitEngine/nunit.engine.core/Internal/TestAssemblyLoadContext.cs b/src/NUnitEngine/nunit.engine.core/Internal/TestAssemblyLoadContext.cs index 800de29da..93c37ced1 100644 --- a/src/NUnitEngine/nunit.engine.core/Internal/TestAssemblyLoadContext.cs +++ b/src/NUnitEngine/nunit.engine.core/Internal/TestAssemblyLoadContext.cs @@ -65,10 +65,14 @@ protected override Assembly Load(AssemblyName name) // but are not fully specified in test assembly deps.json file. This happens when the // dependencies reference in the csproj file has CopyLocal=false, and for example, the // reference is a projectReference and has the same output directory as the parent. - string assemblyPath = Path.Combine(_basePath, name.Name + ".dll"); - if (File.Exists(assemblyPath)) + foreach (var extension in new string[] { ".dll", ".exe" }) { - loadedAssembly = LoadFromAssemblyPath(assemblyPath); + string assemblyPath = Path.Combine(_basePath, name.Name + extension); + if (File.Exists(assemblyPath)) + { + loadedAssembly = LoadFromAssemblyPath(assemblyPath); + break; + } } if (loadedAssembly != null)