Skip to content

Commit

Permalink
Check for dotnet in DOTNET_INSTALL_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
zijchen authored Feb 9, 2024
1 parent 9b74678 commit 8374610
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/Microsoft.Build.Sql.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Build.Sql.Tests
public static class TestUtils
{
private const string DotnetToolPathEnvironmentVariable = "DOTNET_TOOL_PATH";
private const string DotnetInstallDirEnvironmentVariable = "DOTNET_INSTALL_DIR";

/// <summary>
/// Returns the full path to the dotnet executable based on the current operating system.
Expand All @@ -18,7 +19,7 @@ public static class TestUtils
public static string GetDotnetPath()
{
string dotnetExecutable = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dotnet.exe" : "dotnet";
string? dotnetPath = Environment.GetEnvironmentVariable(DotnetToolPathEnvironmentVariable);
string? dotnetPath = Environment.GetEnvironmentVariable(DotnetToolPathEnvironmentVariable) ?? Environment.GetEnvironmentVariable(DotnetInstallDirEnvironmentVariable);
if (string.IsNullOrEmpty(dotnetPath))
{
// Determine OS specific dotnet installation path
Expand Down Expand Up @@ -73,4 +74,4 @@ public static void CopyDirectoryRecursive(string sourceDirectoryPath, string tar
}
}
}
}
}

0 comments on commit 8374610

Please sign in to comment.