Skip to content

Commit

Permalink
fix: a problem where dotnet wasn't found on some linux systems
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsfoni committed Dec 29, 2023
1 parent 34cc4e5 commit 0053011
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
31 changes: 3 additions & 28 deletions CycloneDX/Services/DotnetCommandService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,34 +100,9 @@ private static string GetDotnetPathOrDefault()
}
// DOTNET_ROOT specifies the location of the .NET runtimes, if they are not installed in the default location.
var dotnetRoot = Environment.GetEnvironmentVariable("DOTNET_ROOT");

if (string.IsNullOrEmpty(dotnetRoot))
{
// fall back to default location
// https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_root-dotnet_rootx86

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);
return !string.IsNullOrEmpty(dotnetRoot)
? Path.Combine(dotnetRoot, fileName)
: fileName;
}

private static async Task ConsumeStreamReaderAsync(StreamReader reader, StringBuilder lines)
Expand Down
2 changes: 1 addition & 1 deletion semver.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1
3.0.2

0 comments on commit 0053011

Please sign in to comment.