@@ -836,9 +836,21 @@ private static async Task<int> ExecuteInIsolatedProcessCoreAsync(
836836 string sessionId ,
837837 CancellationToken cancellationToken )
838838 {
839+ if ( string . IsNullOrWhiteSpace ( hostAssemblyPath ) )
840+ {
841+ throw new FileNotFoundException ( "Execution host path is missing." ) ;
842+ }
843+
844+ var resolvedHostPath = Path . GetFullPath ( hostAssemblyPath ) ;
845+ var useDotNetCli = string . Equals (
846+ Path . GetExtension ( resolvedHostPath ) ,
847+ ".dll" ,
848+ StringComparison . OrdinalIgnoreCase ) ;
849+
839850 var startInfo = new ProcessStartInfo
840851 {
841- FileName = "dotnet" ,
852+ // Prefer the bundled execution host if available to avoid relying on a global dotnet CLI.
853+ FileName = useDotNetCli ? "dotnet" : resolvedHostPath ,
842854 WorkingDirectory = workingDirectory ,
843855 RedirectStandardOutput = true ,
844856 RedirectStandardError = true ,
@@ -849,7 +861,10 @@ private static async Task<int> ExecuteInIsolatedProcessCoreAsync(
849861 StandardErrorEncoding = Encoding . UTF8
850862 } ;
851863
852- startInfo . ArgumentList . Add ( hostAssemblyPath ) ;
864+ if ( useDotNetCli )
865+ {
866+ startInfo . ArgumentList . Add ( resolvedHostPath ) ;
867+ }
853868 startInfo . ArgumentList . Add ( "--assembly" ) ;
854869 startInfo . ArgumentList . Add ( compiledAssemblyPath ) ;
855870 startInfo . ArgumentList . Add ( "--workingDirectory" ) ;
@@ -1042,13 +1057,30 @@ private static bool IsBenignMacInputMethodMessage(string text)
10421057 private static string LocateExecutionHost ( )
10431058 {
10441059 var baseDirectory = AppContext . BaseDirectory ;
1045- var candidates = new [ ]
1060+ var rawCandidates = new [ ]
10461061 {
1047- Path . Combine ( baseDirectory , "ExecutionHost" , "SharpPad.ExecutionHost.dll " ) ,
1048- Path . Combine ( baseDirectory , "SharpPad.ExecutionHost.dll " ) ,
1049- Path . Combine ( baseDirectory , ".." , "ExecutionHost" , "SharpPad.ExecutionHost.dll " )
1062+ Path . Combine ( baseDirectory , "ExecutionHost" , "SharpPad.ExecutionHost" ) ,
1063+ Path . Combine ( baseDirectory , "SharpPad.ExecutionHost" ) ,
1064+ Path . Combine ( baseDirectory , ".." , "ExecutionHost" , "SharpPad.ExecutionHost" )
10501065 } ;
10511066
1067+ var candidates = new List < string > ( ) ;
1068+ foreach ( var raw in rawCandidates )
1069+ {
1070+ if ( string . IsNullOrWhiteSpace ( raw ) )
1071+ {
1072+ continue ;
1073+ }
1074+
1075+ if ( OperatingSystem . IsWindows ( ) )
1076+ {
1077+ candidates . Add ( raw + ".exe" ) ;
1078+ }
1079+
1080+ candidates . Add ( raw ) ;
1081+ candidates . Add ( raw + ".dll" ) ;
1082+ }
1083+
10521084 foreach ( var candidate in candidates )
10531085 {
10541086 var fullPath = Path . GetFullPath ( candidate ) ;
0 commit comments