@@ -196,17 +196,17 @@ private sealed class CachedState
196
196
minimumVSDefinedSDKVersion ) ;
197
197
}
198
198
199
- string ? dotnetExe =
200
- TryResolveDotnetExeFromSdkResolution ( resolverResult )
199
+ string ? fullPathToMuxer =
200
+ TryResolveMuxerFromSdkResolution ( resolverResult )
201
201
?? Path . Combine ( dotnetRoot , RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? Constants . DotNetExe : Constants . DotNet ) ;
202
- if ( File . Exists ( dotnetExe ) )
202
+ if ( File . Exists ( fullPathToMuxer ) )
203
203
{
204
204
propertiesToAdd ??= new Dictionary < string , string ? > ( ) ;
205
- propertiesToAdd . Add ( DotnetHostExperimentalKey , dotnetExe ) ;
205
+ propertiesToAdd . Add ( DotnetHostExperimentalKey , fullPathToMuxer ) ;
206
206
}
207
207
else
208
208
{
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.") ;
210
210
}
211
211
212
212
string ? runtimeVersion = dotnetRoot != null ?
@@ -288,22 +288,23 @@ private sealed class CachedState
288
288
return factory . IndicateSuccess ( msbuildSdkDir , netcoreSdkVersion , propertiesToAdd , itemsToAdd , warnings ) ;
289
289
}
290
290
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 )
293
299
{
294
300
var expectedFileName = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? Constants . DotNetExe : Constants . DotNet ;
295
301
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 ) )
297
305
{
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 ;
305
307
}
306
-
307
308
return null ;
308
309
}
309
310
0 commit comments