Skip to content

Commit 3e3b43d

Browse files
committed
Give error if x86 version of dotnet is needed but not available
1 parent 714ada1 commit 3e3b43d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/NUnitEngine/nunit.engine/Services/AgentProcess.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,22 @@ public AgentProcess(TestAgency agency, TestPackage package, Guid agentId)
6363
}
6464
else if (TargetRuntime.Runtime == RuntimeType.NetCore)
6565
{
66-
StartInfo.FileName = runAsX86
67-
? @"C:\Program Files (x86)\dotnet\dotnet.exe"
68-
: "dotnet";
66+
StartInfo.FileName = "dotnet";
6967
StartInfo.Arguments = $"{AgentExePath} {AgentArgs}";
7068
StartInfo.LoadUserProfile = loadUserProfile;
69+
70+
// TODO: Remove the windows limitation and the use of a hard-coded path.
71+
if (runAsX86)
72+
{
73+
if (Path.DirectorySeparatorChar != '\\')
74+
throw new Exception("Running .NET Core as X86 is currently only supported on Windows");
75+
76+
var x86_dotnet_exe = @"C:\Program Files (x86)\dotnet\dotnet.exe";
77+
if (!File.Exists(x86_dotnet_exe))
78+
throw new Exception("The X86 version of dotnet.exe is not installed");
79+
80+
StartInfo.FileName = x86_dotnet_exe;
81+
}
7182
}
7283
else
7384
{
@@ -78,7 +89,7 @@ public AgentProcess(TestAgency agency, TestPackage package, Guid agentId)
7889

7990
// Internal properties exposed for testing
8091

81-
internal RuntimeFramework TargetRuntime { get; }
92+
internal RuntimeFramework TargetRuntime { get; }
8293
internal string AgentExePath { get; }
8394
internal StringBuilder AgentArgs { get; }
8495

0 commit comments

Comments
 (0)