-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathToolsetUtils.cs
43 lines (36 loc) · 2 KB
/
ToolsetUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.NET.Build.Containers.IntegrationTests;
internal static class ToolsetUtils
{
/// <summary>
/// Gets path to RuntimeIdentifierGraph.json file.
/// </summary>
/// <returns></returns>
internal static string GetRuntimeGraphFilePath()
{
return TestContext.GetRuntimeGraphFilePath();
}
internal static IManifestPicker RidGraphManifestPicker { get; } = new RidGraphManifestPicker(GetRuntimeGraphFilePath());
/// <summary>
/// Gets path to built Microsoft.NET.Build.Containers.*.nupkg prepared for tests.
/// </summary>
/// <returns></returns>
internal static (string? PackagePath, string? PackageVersion) GetContainersPackagePath()
{
string packageDir = Path.Combine(TestContext.Current.TestExecutionDirectory, "Container", "package");
//until the package is stabilized, the package version matches TestContext.Current.ToolsetUnderTest.SdkVersion
//after the package is stabilized, the package version doesn't have -prefix (-dev, -ci) anymore
//so one of those is expected
string?[] expectedPackageVersions = new[] { TestContext.Current.ToolsetUnderTest?.SdkVersion, TestContext.Current.ToolsetUnderTest?.SdkVersion?.Split('-')[0] };
foreach (string? expectedVersion in expectedPackageVersions)
{
string? fullFileName = Path.Combine(packageDir, $"Microsoft.NET.Build.Containers.{expectedVersion}.nupkg");
if (File.Exists(fullFileName))
{
return (fullFileName, expectedVersion);
}
}
throw new FileNotFoundException($"No Microsoft.NET.Build.Containers.*.nupkg found in expected package folder {packageDir}. Tried the following package versions: {string.Join(", ", expectedPackageVersions.Select(v => $"'Microsoft.NET.Build.Containers.{v}.nupkg'"))}. You may need to rerun the build.");
}
}