diff --git a/CycloneDX/Services/DotnetCommandService.cs b/CycloneDX/Services/DotnetCommandService.cs index 785ec86f..f953a0c6 100644 --- a/CycloneDX/Services/DotnetCommandService.cs +++ b/CycloneDX/Services/DotnetCommandService.cs @@ -93,7 +93,7 @@ private static string GetDotnetPathOrDefault() fileName += ".exe"; } var mainModule = Process.GetCurrentProcess().MainModule; - if (!string.IsNullOrEmpty(mainModule.FileName) + if (!string.IsNullOrEmpty(mainModule?.FileName) && Path.GetFileName(mainModule.FileName).Equals(fileName, StringComparison.OrdinalIgnoreCase)) { return mainModule.FileName; @@ -105,13 +105,32 @@ private static string GetDotnetPathOrDefault() { // fall back to default location // https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_root-dotnet_rootx86 - dotnetRoot = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\Program Files\\dotnet" : "/usr/local/share/dotnet"; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + dotnetRoot = "C:\\Program Files\\dotnet"; + + } + else + { + dotnetRoot = "/usr/local/share/dotnet"; + if (!Directory.Exists(dotnetRoot)) + { + dotnetRoot = "/usr/share/dotnet"; + } + if (!Directory.Exists(dotnetRoot)) + { + dotnetRoot = "/usr/lib/dotnet"; + } + } + + } return Path.Combine(dotnetRoot, fileName); } - private static async Task ConsumeStreamReaderAsync(StreamReader reader, StringBuilder lines) + private static async Task ConsumeStreamReaderAsync(StreamReader reader, StringBuilder lines) { await Task.Yield(); diff --git a/semver.txt b/semver.txt index 4a36342f..cb2b00e4 100755 --- a/semver.txt +++ b/semver.txt @@ -1 +1 @@ -3.0.0 +3.0.1