Skip to content

Commit 37684cc

Browse files
committed
Pick a rid graph at semi-random for testing
We don't do anything too complicated so 'most recent'-ish should be fine.
1 parent af582c5 commit 37684cc

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Test.Microsoft.NET.Build.Containers.Filesystem/CreateNewImageTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ namespace Test.Microsoft.NET.Build.Containers.Tasks;
99
[TestClass]
1010
public class CreateNewImageTests
1111
{
12-
public static string RuntimeGraphFilePath() =>
13-
// TODO: The DOTNET_ROOT comes from the test host, but we have no idea what the SDK version is.
14-
Path.Combine(Environment.GetEnvironmentVariable("DOTNET_ROOT"), "sdk", "7.0.100", "RuntimeIdentifierGraph.json");
15-
12+
public static string RuntimeGraphFilePath() {
13+
DirectoryInfo sdksDir = new(Path.Combine(Environment.GetEnvironmentVariable("DOTNET_ROOT"), "sdk"));
14+
15+
var lastWrittenSdk = sdksDir.EnumerateDirectories().OrderByDescending(di => di.LastWriteTime).First();
16+
17+
return lastWrittenSdk.GetFiles("RuntimeIdentifierGraph.json").Single().FullName;
18+
}
19+
1620
[TestMethod]
1721
public void CreateNewImage_Baseline()
1822
{

Test.Microsoft.NET.Build.Containers.Filesystem/EndToEnd.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ namespace Test.Microsoft.NET.Build.Containers.Filesystem;
1010
[TestClass]
1111
public class EndToEnd
1212
{
13-
public static string RuntimeGraphFilePath() =>
14-
// TODO: The DOTNET_ROOT comes from the test host, but we have no idea what the SDK version is.
15-
Path.Combine(Environment.GetEnvironmentVariable("DOTNET_ROOT"), "sdk", "7.0.100", "RuntimeIdentifierGraph.json");
13+
public static string RuntimeGraphFilePath() {
14+
DirectoryInfo sdksDir = new(Path.Combine(Environment.GetEnvironmentVariable("DOTNET_ROOT"), "sdk"));
15+
16+
var lastWrittenSdk = sdksDir.EnumerateDirectories().OrderByDescending(di => di.LastWriteTime).First();
17+
18+
return lastWrittenSdk.GetFiles("RuntimeIdentifierGraph.json").Single().FullName;
19+
}
1620

1721
public static string NewImageName([CallerMemberName] string callerMemberName = "")
1822
{

0 commit comments

Comments
 (0)