@@ -196,17 +196,17 @@ private sealed class CachedState
196196 minimumVSDefinedSDKVersion ) ;
197197 }
198198
199- string ? dotnetExe =
200- TryResolveDotnetExeFromSdkResolution ( resolverResult )
199+ string ? fullPathToMuxer =
200+ TryResolveMuxerFromSdkResolution ( resolverResult )
201201 ?? Path . Combine ( dotnetRoot , RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? Constants . DotNetExe : Constants . DotNet ) ;
202- if ( File . Exists ( dotnetExe ) )
202+ if ( File . Exists ( fullPathToMuxer ) )
203203 {
204204 propertiesToAdd ??= new Dictionary < string , string ? > ( ) ;
205- propertiesToAdd . Add ( DotnetHostExperimentalKey , dotnetExe ) ;
205+ propertiesToAdd . Add ( DotnetHostExperimentalKey , fullPathToMuxer ) ;
206206 }
207207 else
208208 {
209- logger ? . LogMessage ( $ "Could not set '{ DotnetHostExperimentalKey } ' because dotnet executable '{ dotnetExe } ' does not exist.") ;
209+ logger ? . LogMessage ( $ "Could not set '{ DotnetHostExperimentalKey } ' because dotnet executable '{ fullPathToMuxer } ' does not exist.") ;
210210 }
211211
212212 string ? runtimeVersion = dotnetRoot != null ?
@@ -288,22 +288,23 @@ private sealed class CachedState
288288 return factory . IndicateSuccess ( msbuildSdkDir , netcoreSdkVersion , propertiesToAdd , itemsToAdd , warnings ) ;
289289 }
290290
291- /// <summary>Try to find the dotnet binary from the SDK resolution result upwards</summary>
292- private static string ? TryResolveDotnetExeFromSdkResolution ( SdkResolutionResult resolverResult )
291+ /// <summary>
292+ /// Try to find the muxer binary from the SDK resolution result.
293+ /// </summary>
294+ /// <remarks>
295+ /// SDK layouts always have a defined relationship to the location of the muxer -
296+ /// the muxer binary should be exactly two directories above the SDK directory.
297+ /// </remarks>
298+ private static string ? TryResolveMuxerFromSdkResolution ( SdkResolutionResult resolverResult )
293299 {
294300 var expectedFileName = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? Constants . DotNetExe : Constants . DotNet ;
295301 var currentDir = resolverResult . ResolvedSdkDirectory ;
296- while ( currentDir != null )
302+ var expectedDotnetRoot = Path . GetDirectoryName ( Path . GetDirectoryName ( currentDir ) ) ;
303+ var expectedMuxerPath = Path . Combine ( expectedDotnetRoot , expectedFileName ) ;
304+ if ( File . Exists ( expectedMuxerPath ) )
297305 {
298- var dotnetExe = Path . Combine ( currentDir , expectedFileName ) ;
299- if ( File . Exists ( dotnetExe ) )
300- {
301- return dotnetExe ;
302- }
303-
304- currentDir = Path . GetDirectoryName ( currentDir ) ;
306+ return expectedMuxerPath ;
305307 }
306-
307308 return null ;
308309 }
309310
0 commit comments