From 3fbac9a8af62a3046605d7f89cc3eb7dbd0c0b4d Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 2 Dec 2020 16:32:32 -0800 Subject: [PATCH 1/3] Update stage 0 Includes NETCoreSdkRuntimeIdentifierChain.txt file --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 46d33c28a149..c9a8b6912ba4 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100", + "dotnet": "5.0.200-preview.20601.7", "runtimes": { "dotnet": [ "$(MicrosoftNETCoreAppInternalPackageVersion)" From 26b1a0fca1b3ac754b6545ff57b8e559c2b3a66d Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 2 Dec 2020 20:47:22 -0800 Subject: [PATCH 2/3] Read current runtime identifiers for workload resolver --- .../redist/targets/OverlaySdkOnLKG.targets | 1 + .../TemplateLocator.cs | 5 +- .../WorkloadSdkResolver.cs | 5 +- .../WorkloadPack.cs | 6 +-- .../WorkloadResolver.cs | 49 ++----------------- .../ManifestReaderFunctionalTests.cs | 6 +-- .../ManifestTests.cs | 5 +- 7 files changed, 22 insertions(+), 55 deletions(-) diff --git a/src/Layout/redist/targets/OverlaySdkOnLKG.targets b/src/Layout/redist/targets/OverlaySdkOnLKG.targets index 9d7b137f9036..d41b279aee33 100644 --- a/src/Layout/redist/targets/OverlaySdkOnLKG.targets +++ b/src/Layout/redist/targets/OverlaySdkOnLKG.targets @@ -14,6 +14,7 @@ + diff --git a/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs b/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs index 13230a15214b..e31191481652 100644 --- a/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs +++ b/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs @@ -50,8 +50,11 @@ public IReadOnlyCollection GetDotnetSdkTemplate nameof(dotnetRootPath)); } + string runtimeIdentifierChainPath = Path.Combine(dotnetRootPath, "sdk", sdkVersion, "NETCoreSdkRuntimeIdentifierChain.txt"); + string[] currentRuntimeIdentifiers = File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray(); + _workloadManifestProvider ??= new SdkDirectoryWorkloadManifestProvider(dotnetRootPath, sdkVersion); - _workloadResolver ??= new WorkloadResolver(_workloadManifestProvider, dotnetRootPath); + _workloadResolver ??= new WorkloadResolver(_workloadManifestProvider, dotnetRootPath, currentRuntimeIdentifiers); return _workloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind.Template) .Select(pack => new OptionalSdkTemplatePackageInfo(pack.Id, pack.Version, pack.Path)).ToList(); diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs index 3cef352ed9e1..53fdb691684c 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs @@ -71,9 +71,12 @@ private void InitializeWorkloadResolver(SdkResolverContext context) // The SDK version is the name of the SDK directory (ie dotnet\sdk\5.0.100) var sdkVersion = Path.GetFileName(sdkDirectory); + string runtimeIdentifierChainPath = Path.Combine(sdkDirectory, "NETCoreSdkRuntimeIdentifierChain.txt"); + string[] currentRuntimeIdentifiers = File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray(); + _workloadManifestProvider ??= new SdkDirectoryWorkloadManifestProvider(dotnetRootPath, sdkVersion); - _workloadResolver ??= new WorkloadResolver(_workloadManifestProvider, dotnetRootPath); + _workloadResolver ??= new WorkloadResolver(_workloadManifestProvider, dotnetRootPath, currentRuntimeIdentifiers); } public override SdkResult Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory) diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadPack.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadPack.cs index 2287d9145460..f9743ad0c832 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadPack.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadPack.cs @@ -21,16 +21,16 @@ public WorkloadPack(WorkloadPackId id, string version, WorkloadPackKind kind, Di public bool IsAlias => AliasTo != null && AliasTo.Count > 0; public Dictionary? AliasTo { get; } - public WorkloadPackId? TryGetAliasForPlatformIds (IEnumerable platformIds) + public WorkloadPackId? TryGetAliasForRuntimeIdentifiers(IEnumerable runtimeIdentifiers) { if (AliasTo == null || AliasTo.Count == 0) { return null; } - foreach (var platformId in platformIds) + foreach (var runtimeIdentifier in runtimeIdentifiers) { - if (AliasTo.TryGetValue(platformId, out WorkloadPackId alias)) + if (AliasTo.TryGetValue(runtimeIdentifier, out WorkloadPackId alias)) { return alias; } diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs index 67b0852f6369..3b7d1920a1ba 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs @@ -17,27 +17,17 @@ public class WorkloadResolver : IWorkloadResolver { private readonly Dictionary _workloads = new Dictionary(); private readonly Dictionary _packs = new Dictionary(); - private string[] _platformIds; + private string[] _currentRuntimeIdentifiers; private readonly string _dotNetRootPath; private Func? _fileExistOverride; private Func? _directoryExistOverride; - public WorkloadResolver(IWorkloadManifestProvider manifestProvider, string dotNetRootPath) + public WorkloadResolver(IWorkloadManifestProvider manifestProvider, string dotNetRootPath, string [] currentRuntimeIdentifiers) { this._dotNetRootPath = dotNetRootPath; - // eventually we may want a series of fallbacks here, as rids have in general - // but for now, keep it simple - var platformId = GetHostPlatformId(); - if (platformId != null) - { - _platformIds = new[] { platformId, "*" }; - } - else - { - _platformIds = new[] { "*" }; - } + _currentRuntimeIdentifiers = currentRuntimeIdentifiers; var manifests = new List(); @@ -63,32 +53,6 @@ public WorkloadResolver(IWorkloadManifestProvider manifestProvider, string dotNe } } - - // rather that forcing all consumers to depend on and parse the RID catalog, or doing that here, for now just bake in a small - // subset of dev host platform rids for now for the workloads that are likely to need this functionality soonest - private string? GetHostPlatformId() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return RuntimeInformation.OSArchitecture switch - { - Architecture.X64 => "osx-x64", - Architecture.Arm64 => "osx-arm64", - _ => null - }; - } - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - if (RuntimeInformation.OSArchitecture == Architecture.X64) - { - return "win-x64"; - } - } - - return null; - } - /// /// Gets the installed workload packs of a particular kind /// @@ -119,14 +83,9 @@ internal void ReplaceFilesystemChecksForTest(Func fileExists, Func _directoryExistOverride = directoryExists; } - internal void ReplacePlatformIdsForTest(string[] platformIds) - { - this._platformIds = platformIds; - } - private PackInfo CreatePackInfo(WorkloadPack pack) { - var aliasedId = pack.TryGetAliasForPlatformIds(_platformIds) ?? pack.Id; + var aliasedId = pack.TryGetAliasForRuntimeIdentifiers(_currentRuntimeIdentifiers) ?? pack.Id; var packPath = GetPackPath(_dotNetRootPath, aliasedId, pack.Version, pack.Kind); return new PackInfo( diff --git a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs index c44a19faa2f6..416344c71c2b 100644 --- a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs +++ b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs @@ -43,7 +43,7 @@ private static WorkloadResolver SetUp() { var workloadResolver = new WorkloadResolver(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), - "fakepath"); + "fakepath", ManifestTests.TEST_RUNTIME_IDENTIFIER_CHAIN); workloadResolver.ReplaceFilesystemChecksForTest(fileExists: (_) => true, directoryExists: (_) => true); return workloadResolver; @@ -54,7 +54,7 @@ public void GivenTemplateNupkgDoesNotExistOnDiskItShouldReturnEmpty() { var workloadResolver = new WorkloadResolver(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), - "fakepath"); + "fakepath", ManifestTests.TEST_RUNTIME_IDENTIFIER_CHAIN); workloadResolver.ReplaceFilesystemChecksForTest(fileExists: (_) => false, directoryExists: (_) => true); var result = workloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind.Template); result.Should().HaveCount(0); @@ -65,7 +65,7 @@ public void GivenWorkloadSDKsDirectoryNotExistOnDiskItShouldReturnEmpty() { var workloadResolver = new WorkloadResolver(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), - "fakepath"); + "fakepath", ManifestTests.TEST_RUNTIME_IDENTIFIER_CHAIN); workloadResolver.ReplaceFilesystemChecksForTest(fileExists: (_) => true, directoryExists: (_) => false); var result = workloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind.Sdk); result.Should().HaveCount(0); diff --git a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs index 84b1f85d2a19..00fb1fb4357c 100644 --- a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs +++ b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs @@ -13,6 +13,8 @@ public class ManifestTests { private const string fakeRootPath = "fakeRootPath"; + public static readonly string[] TEST_RUNTIME_IDENTIFIER_CHAIN = new[] { "win-x64", "win", "any", "base" }; + [Fact] public void ItCanDeserialize() { @@ -33,10 +35,9 @@ public void ItCanDeserialize() public void AliasedPackPath() { var manifestProvider = new FakeManifestProvider(Path.Combine("Manifests", "Sample.json")); - var resolver = new WorkloadResolver(manifestProvider, fakeRootPath); + var resolver = new WorkloadResolver(manifestProvider, fakeRootPath, TEST_RUNTIME_IDENTIFIER_CHAIN); resolver.ReplaceFilesystemChecksForTest(_ => true, _ => true); - resolver.ReplacePlatformIdsForTest(new[] { "win-x64", "*" }); var buildToolsPack = resolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind.Sdk).FirstOrDefault(pack => pack.Id == "Xamarin.Android.BuildTools"); From 89ef7df42f3c7b1cf9b2fa27f31d1f927d984e19 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Thu, 3 Dec 2020 09:52:20 -0800 Subject: [PATCH 3/3] Handle missing runtime identifier chain file in workload resolver --- .../TemplateLocator.cs | 5 +-- .../WorkloadSdkResolver.cs | 6 +--- .../WorkloadResolver.cs | 33 ++++++++++++++----- .../GivenAnTemplateLocator.cs | 10 +++++- .../ManifestReaderFunctionalTests.cs | 6 ++-- .../ManifestTests.cs | 2 +- 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs b/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs index e31191481652..f751449afd35 100644 --- a/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs +++ b/src/Microsoft.DotNet.TemplateLocator/TemplateLocator.cs @@ -50,11 +50,8 @@ public IReadOnlyCollection GetDotnetSdkTemplate nameof(dotnetRootPath)); } - string runtimeIdentifierChainPath = Path.Combine(dotnetRootPath, "sdk", sdkVersion, "NETCoreSdkRuntimeIdentifierChain.txt"); - string[] currentRuntimeIdentifiers = File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray(); - _workloadManifestProvider ??= new SdkDirectoryWorkloadManifestProvider(dotnetRootPath, sdkVersion); - _workloadResolver ??= new WorkloadResolver(_workloadManifestProvider, dotnetRootPath, currentRuntimeIdentifiers); + _workloadResolver ??= WorkloadResolver.Create(_workloadManifestProvider, dotnetRootPath, sdkVersion); return _workloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind.Template) .Select(pack => new OptionalSdkTemplatePackageInfo(pack.Id, pack.Version, pack.Path)).ToList(); diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs index 53fdb691684c..a66af486f287 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/WorkloadSdkResolver.cs @@ -71,12 +71,8 @@ private void InitializeWorkloadResolver(SdkResolverContext context) // The SDK version is the name of the SDK directory (ie dotnet\sdk\5.0.100) var sdkVersion = Path.GetFileName(sdkDirectory); - string runtimeIdentifierChainPath = Path.Combine(sdkDirectory, "NETCoreSdkRuntimeIdentifierChain.txt"); - string[] currentRuntimeIdentifiers = File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray(); - _workloadManifestProvider ??= new SdkDirectoryWorkloadManifestProvider(dotnetRootPath, sdkVersion); - - _workloadResolver ??= new WorkloadResolver(_workloadManifestProvider, dotnetRootPath, currentRuntimeIdentifiers); + _workloadResolver ??= WorkloadResolver.Create(_workloadManifestProvider, dotnetRootPath, sdkVersion); } public override SdkResult Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory) diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs index 3b7d1920a1ba..ea9b30342855 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/WorkloadResolver.cs @@ -18,14 +18,29 @@ public class WorkloadResolver : IWorkloadResolver private readonly Dictionary _workloads = new Dictionary(); private readonly Dictionary _packs = new Dictionary(); private string[] _currentRuntimeIdentifiers; - private readonly string _dotNetRootPath; + private readonly string _dotnetRootPath; private Func? _fileExistOverride; private Func? _directoryExistOverride; - public WorkloadResolver(IWorkloadManifestProvider manifestProvider, string dotNetRootPath, string [] currentRuntimeIdentifiers) + public static WorkloadResolver Create(IWorkloadManifestProvider manifestProvider, string dotnetRootPath, string sdkVersion) { - this._dotNetRootPath = dotNetRootPath; + string runtimeIdentifierChainPath = Path.Combine(dotnetRootPath, "sdk", sdkVersion, "NETCoreSdkRuntimeIdentifierChain.txt"); + string[] currentRuntimeIdentifiers = File.Exists(runtimeIdentifierChainPath) ? + File.ReadAllLines(runtimeIdentifierChainPath).Where(l => !string.IsNullOrEmpty(l)).ToArray() : + new string[] { }; + + return new WorkloadResolver(manifestProvider, dotnetRootPath, currentRuntimeIdentifiers); + } + + public static WorkloadResolver CreateForTests(IWorkloadManifestProvider manifestProvider, string dotNetRootPath, string[] currentRuntimeIdentifiers) + { + return new WorkloadResolver(manifestProvider, dotNetRootPath, currentRuntimeIdentifiers); + } + + private WorkloadResolver(IWorkloadManifestProvider manifestProvider, string dotnetRootPath, string [] currentRuntimeIdentifiers) + { + this._dotnetRootPath = dotnetRootPath; _currentRuntimeIdentifiers = currentRuntimeIdentifiers; @@ -86,7 +101,7 @@ internal void ReplaceFilesystemChecksForTest(Func fileExists, Func private PackInfo CreatePackInfo(WorkloadPack pack) { var aliasedId = pack.TryGetAliasForRuntimeIdentifiers(_currentRuntimeIdentifiers) ?? pack.Id; - var packPath = GetPackPath(_dotNetRootPath, aliasedId, pack.Version, pack.Kind); + var packPath = GetPackPath(_dotnetRootPath, aliasedId, pack.Version, pack.Kind); return new PackInfo( pack.Id.ToString(), @@ -114,19 +129,19 @@ private bool PackExists (PackInfo packInfo) } } - private static string GetPackPath (string dotNetRootPath, WorkloadPackId packageId, string packageVersion, WorkloadPackKind kind) + private static string GetPackPath (string dotnetRootPath, WorkloadPackId packageId, string packageVersion, WorkloadPackKind kind) { switch (kind) { case WorkloadPackKind.Framework: case WorkloadPackKind.Sdk: - return Path.Combine(dotNetRootPath, "packs", packageId.ToString(), packageVersion); + return Path.Combine(dotnetRootPath, "packs", packageId.ToString(), packageVersion); case WorkloadPackKind.Template: - return Path.Combine(dotNetRootPath, "template-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg"); + return Path.Combine(dotnetRootPath, "template-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg"); case WorkloadPackKind.Library: - return Path.Combine(dotNetRootPath, "library-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg"); + return Path.Combine(dotnetRootPath, "library-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg"); case WorkloadPackKind.Tool: - return Path.Combine(dotNetRootPath, "tool-packs", packageId.ToString(), packageVersion); + return Path.Combine(dotnetRootPath, "tool-packs", packageId.ToString(), packageVersion); default: throw new ArgumentException($"The package kind '{kind}' is not known", nameof(kind)); } diff --git a/src/Tests/Microsoft.DotNet.TemplateLocator.Tests/GivenAnTemplateLocator.cs b/src/Tests/Microsoft.DotNet.TemplateLocator.Tests/GivenAnTemplateLocator.cs index 890853532dea..260fa23c4173 100644 --- a/src/Tests/Microsoft.DotNet.TemplateLocator.Tests/GivenAnTemplateLocator.cs +++ b/src/Tests/Microsoft.DotNet.TemplateLocator.Tests/GivenAnTemplateLocator.cs @@ -23,8 +23,16 @@ public GivenAnTemplateLocator(ITestOutputHelper logger) : base(logger) _resolver = new TemplateLocator(Environment.GetEnvironmentVariable, VSSettings.Ambient, null, null); _fakeDotnetRootDirectory = Path.Combine(TestContext.Current.TestExecutionDirectory, Path.GetRandomFileName()); + + var fakeSdkDirectory = Path.Combine(_fakeDotnetRootDirectory, "sdk", "5.0.102"); + Directory.CreateDirectory(fakeSdkDirectory); + var fakeRuntimeIdentifierChainPath = Path.Combine(fakeSdkDirectory, "NETCoreSdkRuntimeIdentifierChain.txt"); + File.WriteAllLines(fakeRuntimeIdentifierChainPath, + new[] { "win-x64", "win", "any", "base" }); + _manifestDirectory = Path.Combine(_fakeDotnetRootDirectory, "sdk-manifests", "5.0.100"); Directory.CreateDirectory(_manifestDirectory); + } [Fact] @@ -64,7 +72,7 @@ public void GivenNoManifestDirectoryItShouldReturnEmpty() { var fakeDotnetRootDirectory = Path.Combine(TestContext.Current.TestExecutionDirectory, Path.GetRandomFileName()); - var result = _resolver.GetDotnetSdkTemplatePackages("5.1.102", fakeDotnetRootDirectory); + var result = _resolver.GetDotnetSdkTemplatePackages("5.0.102", fakeDotnetRootDirectory); result.Should().BeEmpty(); } } diff --git a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs index 416344c71c2b..ed4347bb98a1 100644 --- a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs +++ b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestReaderFunctionalTests.cs @@ -42,7 +42,7 @@ public void ItShouldGetAllSdkPacks() private static WorkloadResolver SetUp() { var workloadResolver = - new WorkloadResolver(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), + WorkloadResolver.CreateForTests(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), "fakepath", ManifestTests.TEST_RUNTIME_IDENTIFIER_CHAIN); workloadResolver.ReplaceFilesystemChecksForTest(fileExists: (_) => true, directoryExists: (_) => true); @@ -53,7 +53,7 @@ private static WorkloadResolver SetUp() public void GivenTemplateNupkgDoesNotExistOnDiskItShouldReturnEmpty() { var workloadResolver = - new WorkloadResolver(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), + WorkloadResolver.CreateForTests(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), "fakepath", ManifestTests.TEST_RUNTIME_IDENTIFIER_CHAIN); workloadResolver.ReplaceFilesystemChecksForTest(fileExists: (_) => false, directoryExists: (_) => true); var result = workloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind.Template); @@ -64,7 +64,7 @@ public void GivenTemplateNupkgDoesNotExistOnDiskItShouldReturnEmpty() public void GivenWorkloadSDKsDirectoryNotExistOnDiskItShouldReturnEmpty() { var workloadResolver = - new WorkloadResolver(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), + WorkloadResolver.CreateForTests(new FakeManifestProvider(new[] {Path.Combine("Manifests", "Sample.json")}), "fakepath", ManifestTests.TEST_RUNTIME_IDENTIFIER_CHAIN); workloadResolver.ReplaceFilesystemChecksForTest(fileExists: (_) => true, directoryExists: (_) => false); var result = workloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind.Sdk); diff --git a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs index 00fb1fb4357c..9c54eb0849d2 100644 --- a/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs +++ b/src/Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/ManifestTests.cs @@ -35,7 +35,7 @@ public void ItCanDeserialize() public void AliasedPackPath() { var manifestProvider = new FakeManifestProvider(Path.Combine("Manifests", "Sample.json")); - var resolver = new WorkloadResolver(manifestProvider, fakeRootPath, TEST_RUNTIME_IDENTIFIER_CHAIN); + var resolver = WorkloadResolver.CreateForTests(manifestProvider, fakeRootPath, TEST_RUNTIME_IDENTIFIER_CHAIN); resolver.ReplaceFilesystemChecksForTest(_ => true, _ => true);