Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

85 lines
2.7 KiB
C#
Raw Permalink Normal View History

2017-12-18 16:14:47 -08:00
// 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;
2016-09-15 02:03:49 -07:00
using System.IO;
namespace NuGet.Test.Utility
{
/// <summary>
/// Create a basic test layout complete with a nuget.config file containing the paths
/// </summary>
public class SimpleTestPathContext : IDisposable
{
/// <summary>
/// Root working directory
/// </summary>
2016-09-15 02:03:49 -07:00
public TestDirectory WorkingDirectory { get; }
/// <summary>
/// Solution folder
/// </summary>
2016-09-15 02:03:49 -07:00
public string SolutionRoot { get; }
/// <summary>
/// PackageReference install location
/// </summary>
2016-09-15 02:03:49 -07:00
public string UserPackagesFolder { get; }
/// <summary>
/// Packages.config install location
/// </summary>
2016-09-15 02:03:49 -07:00
public string PackagesV2 { get; }
/// <summary>
/// NuGet.Config path
/// </summary>
2016-09-15 02:03:49 -07:00
public string NuGetConfig { get; }
/// <summary>
/// Local package source
/// </summary>
2016-09-15 02:03:49 -07:00
public string PackageSource { get; }
/// <summary>
/// Fallback folder
/// </summary>
2016-09-15 02:03:49 -07:00
public string FallbackFolder { get; }
/// <summary>
/// Http cache location
/// </summary>
public string HttpCacheFolder { get; }
/// <summary>
/// settings from <see cref="NuGetConfig"/>
/// </summary>
public SimpleTestSettingsContext Settings { get; }
2016-09-15 02:03:49 -07:00
public SimpleTestPathContext()
{
WorkingDirectory = TestDirectory.Create();
2016-09-15 02:03:49 -07:00
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");
2016-09-15 02:03:49 -07:00
Directory.CreateDirectory(SolutionRoot);
Directory.CreateDirectory(UserPackagesFolder);
Directory.CreateDirectory(PackageSource);
Directory.CreateDirectory(FallbackFolder);
Settings = new SimpleTestSettingsContext(NuGetConfig, UserPackagesFolder, PackagesV2, FallbackFolder, PackageSource);
Settings.Save();
2016-09-15 02:03:49 -07:00
}
public void Dispose()
{
2019-07-22 12:13:14 -07:00
WorkingDirectory.Dispose();
2016-09-15 02:03:49 -07:00
}
}
2019-07-22 12:13:14 -07:00
}