Skip to content

Commit dda0049

Browse files
committed
Fix identifying Mono vs CoreCLR runtimes
We currently use `mono-gc.h` as signal that the runtime is a mono-based runtime. Unfortuatnely, that file is only included with 7.0. This makes us mis-identify Mono-based 6.0 runtimes as CoreCLR-based instead. Instead, use libcoreclrtraceptprovider.so which is available CoreCLR-based platforms (eg, x86_64) but not Mono-based ones. This file exists on 6.0 and later: $ find /usr/lib64/dotnet -iname libcoreclrtraceptprovider.so /usr/lib64/dotnet/shared/Microsoft.NETCore.App/8.0.0-preview.5.23280.8/libcoreclrtraceptprovider.so /usr/lib64/dotnet/shared/Microsoft.NETCore.App/7.0.7/libcoreclrtraceptprovider.so /usr/lib64/dotnet/shared/Microsoft.NETCore.App/6.0.18/libcoreclrtraceptprovider.so
1 parent 4e01bbb commit dda0049

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Turkey/DotNet.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ public Version LatestRuntimeVersion
6161
}
6262
}
6363

64+
public bool IsCoreClrRuntime(Version runtimeVersion)
65+
=> IsCoreClrRuntime(DotnetRoot, runtimeVersion);
66+
6467
public bool IsMonoRuntime(Version runtimeVersion)
65-
=> IsMonoRuntime(DotnetRoot, runtimeVersion);
68+
=> !IsCoreClrRuntime(runtimeVersion);
6669

6770
public List<Version> SdkVersions
6871
{
@@ -137,7 +140,7 @@ private async Task<int> RunDotNetCommandAsync(DirectoryInfo workingDirectory, st
137140
return await ProcessRunner.RunAsync(startInfo, logger, token);
138141
}
139142

140-
private static bool IsMonoRuntime(string dotnetRoot, Version version)
143+
private static bool IsCoreClrRuntime(string dotnetRoot, Version version)
141144
{
142145
string[] runtimeDirectories = Directory.GetDirectories(Path.Combine(dotnetRoot, "shared", "Microsoft.NETCore.App"))
143146
.Where(dir => Version.Parse(Path.GetFileName(dir)) == version)
@@ -153,7 +156,7 @@ private static bool IsMonoRuntime(string dotnetRoot, Version version)
153156
}
154157

155158
string runtimeDir = runtimeDirectories[0];
156-
return File.Exists(Path.Combine(runtimeDir, "mono-gc.h"));
159+
return File.Exists(Path.Combine(runtimeDir, "libcoreclrtraceptprovider.so"));
157160
}
158161

159162
private static string? FindProgramInPath(string program)

0 commit comments

Comments
 (0)