Skip to content

Commit

Permalink
Separate testing code for rid resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoslund committed Jul 19, 2021
1 parent bbee38b commit cf134cf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Cli/dotnet/CommonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,20 @@ internal static string ResolveRidShorthandOptionsToRuntimeIdentifier(string os,

private static string GetCurrentRuntimeId()
{
var dotnetRootPath = Path.GetDirectoryName(Environment.ProcessPath);
dotnetRootPath = dotnetRootPath.Contains("dotnet") ? dotnetRootPath : Path.Combine(dotnetRootPath, "dotnet");
string runtimeIdentifierChainPath;
var ridFileName = "NETCoreSdkRuntimeIdentifierChain.txt";
string runtimeIdentifierChainPath = string.IsNullOrEmpty(Product.Version) ?
Path.Combine(Directory.GetDirectories(Path.Combine(dotnetRootPath, "sdk"))[0], ridFileName) :
Path.Combine(dotnetRootPath, "sdk", Product.Version, ridFileName);
if (Path.GetFileName(Environment.ProcessPath).Equals("dotnet.exe"))
{
var dotnetRootPath = Path.GetDirectoryName(Environment.ProcessPath);
runtimeIdentifierChainPath = Path.Combine(dotnetRootPath, "sdk", Product.Version, ridFileName);
}
else
{
// When testing we run under testhost.exe
var dotnetRootPath = Path.GetDirectoryName(Environment.ProcessPath);
dotnetRootPath = dotnetRootPath.Contains("dotnet") ? dotnetRootPath : Path.Combine(dotnetRootPath, "dotnet");
runtimeIdentifierChainPath = Path.Combine(Directory.GetDirectories(Path.Combine(dotnetRootPath, "sdk"))[0], ridFileName);
}
string[] currentRuntimeIdentifiers = File.Exists(runtimeIdentifierChainPath) ?
File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray() :
new string[] { };
Expand Down

0 comments on commit cf134cf

Please sign in to comment.