// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.IO; namespace NuGet.Test.Utility { /// /// Create a basic test layout complete with a nuget.config file containing the paths /// public class SimpleTestPathContext : IDisposable { /// /// Root working directory /// public TestDirectory WorkingDirectory { get; } /// /// Solution folder /// public string SolutionRoot { get; } /// /// PackageReference install location /// public string UserPackagesFolder { get; } /// /// Packages.config install location /// public string PackagesV2 { get; } /// /// NuGet.Config path /// public string NuGetConfig { get; } /// /// Local package source /// public string PackageSource { get; } /// /// Fallback folder /// public string FallbackFolder { get; } /// /// Http cache location /// public string HttpCacheFolder { get; } /// /// settings from /// public SimpleTestSettingsContext Settings { get; } public SimpleTestPathContext() { WorkingDirectory = TestDirectory.Create(); SolutionRoot = Path.Combine(WorkingDirectory.Path, "solution"); UserPackagesFolder = Path.Combine(WorkingDirectory.Path, "globalPackages"); PackagesV2 = Path.Combine(SolutionRoot, "packages"); NuGetConfig = Path.Combine(WorkingDirectory, "NuGet.Config"); PackageSource = Path.Combine(WorkingDirectory.Path, "source"); FallbackFolder = Path.Combine(WorkingDirectory.Path, "fallback"); HttpCacheFolder = Path.Combine(WorkingDirectory.Path, "v3-cache"); Directory.CreateDirectory(SolutionRoot); Directory.CreateDirectory(UserPackagesFolder); Directory.CreateDirectory(PackageSource); Directory.CreateDirectory(FallbackFolder); Settings = new SimpleTestSettingsContext(NuGetConfig, UserPackagesFolder, PackagesV2, FallbackFolder, PackageSource); Settings.Save(); } public void Dispose() { WorkingDirectory.Dispose(); } } }