Make CliFolderPathCalculator
a static class.
The `CliFolderPathCalculator` class implements no interface and has no instance fields. This commit therefore makes it a static class.
This commit is contained in:
parent
8f8770be8a
commit
3e962bc131
19 changed files with 40 additions and 75 deletions
|
@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Configurer
|
||||||
|
|
||||||
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
|
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
|
||||||
|
|
||||||
public AspNetCertificateSentinel(CliFolderPathCalculator cliFallbackFolderPathCalculator) :
|
public AspNetCertificateSentinel() :
|
||||||
this(
|
this(
|
||||||
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
||||||
FileSystemWrapper.Default.File,
|
FileSystemWrapper.Default.File,
|
||||||
|
|
|
@ -8,16 +8,20 @@ using NuGet.Common;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Configurer
|
namespace Microsoft.DotNet.Configurer
|
||||||
{
|
{
|
||||||
public class CliFolderPathCalculator
|
public static class CliFolderPathCalculator
|
||||||
{
|
{
|
||||||
private const string DotnetProfileDirectoryName = ".dotnet";
|
private const string DotnetProfileDirectoryName = ".dotnet";
|
||||||
private const string ToolsShimFolderName = "tools";
|
private const string ToolsShimFolderName = "tools";
|
||||||
|
|
||||||
public string CliFallbackFolderPath => Environment.GetEnvironmentVariable("DOTNET_CLI_TEST_FALLBACKFOLDER") ??
|
public static string CliFallbackFolderPath =>
|
||||||
|
Environment.GetEnvironmentVariable("DOTNET_CLI_TEST_FALLBACKFOLDER") ??
|
||||||
Path.Combine(new DirectoryInfo(AppContext.BaseDirectory).Parent.FullName, "NuGetFallbackFolder");
|
Path.Combine(new DirectoryInfo(AppContext.BaseDirectory).Parent.FullName, "NuGetFallbackFolder");
|
||||||
public string ToolsShimPath => Path.Combine(DotnetUserProfileFolderPath, ToolsShimFolderName);
|
|
||||||
public string ToolsPackagePath => ToolPackageFolderPathCalculator.GetToolPackageFolderPath(ToolsShimPath);
|
public static string ToolsShimPath => Path.Combine(DotnetUserProfileFolderPath, ToolsShimFolderName);
|
||||||
public BashPathUnderHomeDirectory ToolsShimPathInUnix
|
|
||||||
|
public static string ToolsPackagePath => ToolPackageFolderPathCalculator.GetToolPackageFolderPath(ToolsShimPath);
|
||||||
|
|
||||||
|
public static BashPathUnderHomeDirectory ToolsShimPathInUnix
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -37,7 +41,7 @@ namespace Microsoft.DotNet.Configurer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NuGetUserSettingsDirectory =>
|
public static string NuGetUserSettingsDirectory =>
|
||||||
NuGetEnvironment.GetFolderPath(NuGetFolderPath.UserSettingsDirectory);
|
NuGetEnvironment.GetFolderPath(NuGetFolderPath.UserSettingsDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Configurer
|
||||||
|
|
||||||
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
|
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
|
||||||
|
|
||||||
public FirstTimeUseNoticeSentinel(CliFolderPathCalculator cliFolderPathCalculator) :
|
public FirstTimeUseNoticeSentinel() :
|
||||||
this(
|
this(
|
||||||
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
||||||
FileSystemWrapper.Default.File,
|
FileSystemWrapper.Default.File,
|
||||||
|
|
|
@ -17,31 +17,20 @@ namespace Microsoft.DotNet.Configurer
|
||||||
|
|
||||||
private readonly INuGetCacheSentinel _nuGetCacheSentinel;
|
private readonly INuGetCacheSentinel _nuGetCacheSentinel;
|
||||||
|
|
||||||
private readonly CliFolderPathCalculator _cliFolderPathCalculator;
|
public NuGetCachePrimer(INuGetPackagesArchiver nugetPackagesArchiver, INuGetCacheSentinel nuGetCacheSentinel)
|
||||||
|
: this(nugetPackagesArchiver, nuGetCacheSentinel, FileSystemWrapper.Default.File)
|
||||||
public NuGetCachePrimer(
|
|
||||||
INuGetPackagesArchiver nugetPackagesArchiver,
|
|
||||||
INuGetCacheSentinel nuGetCacheSentinel,
|
|
||||||
CliFolderPathCalculator cliFolderPathCalculator)
|
|
||||||
: this(nugetPackagesArchiver,
|
|
||||||
nuGetCacheSentinel,
|
|
||||||
cliFolderPathCalculator,
|
|
||||||
FileSystemWrapper.Default.File)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal NuGetCachePrimer(
|
internal NuGetCachePrimer(
|
||||||
INuGetPackagesArchiver nugetPackagesArchiver,
|
INuGetPackagesArchiver nugetPackagesArchiver,
|
||||||
INuGetCacheSentinel nuGetCacheSentinel,
|
INuGetCacheSentinel nuGetCacheSentinel,
|
||||||
CliFolderPathCalculator cliFolderPathCalculator,
|
|
||||||
IFile file)
|
IFile file)
|
||||||
{
|
{
|
||||||
_nugetPackagesArchiver = nugetPackagesArchiver;
|
_nugetPackagesArchiver = nugetPackagesArchiver;
|
||||||
|
|
||||||
_nuGetCacheSentinel = nuGetCacheSentinel;
|
_nuGetCacheSentinel = nuGetCacheSentinel;
|
||||||
|
|
||||||
_cliFolderPathCalculator = cliFolderPathCalculator;
|
|
||||||
|
|
||||||
_file = file;
|
_file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +41,7 @@ namespace Microsoft.DotNet.Configurer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nuGetFallbackFolder = _cliFolderPathCalculator.CliFallbackFolderPath;
|
var nuGetFallbackFolder = CliFolderPathCalculator.CliFallbackFolderPath;
|
||||||
|
|
||||||
_nugetPackagesArchiver.ExtractArchive(nuGetFallbackFolder);
|
_nugetPackagesArchiver.ExtractArchive(nuGetFallbackFolder);
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ namespace Microsoft.DotNet.Configurer
|
||||||
|
|
||||||
private Stream InProgressSentinel { get; set; }
|
private Stream InProgressSentinel { get; set; }
|
||||||
|
|
||||||
public NuGetCacheSentinel(CliFolderPathCalculator cliFolderPathCalculator) :
|
public NuGetCacheSentinel() :
|
||||||
this(cliFolderPathCalculator.CliFallbackFolderPath,
|
this(CliFolderPathCalculator.CliFallbackFolderPath,
|
||||||
FileSystemWrapper.Default.File,
|
FileSystemWrapper.Default.File,
|
||||||
FileSystemWrapper.Default.Directory)
|
FileSystemWrapper.Default.Directory)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Configurer
|
||||||
private readonly IDirectory _directory;
|
private readonly IDirectory _directory;
|
||||||
private string _dotnetUserProfileFolderPath;
|
private string _dotnetUserProfileFolderPath;
|
||||||
|
|
||||||
public UserLevelCacheWriter(CliFolderPathCalculator cliFolderPathCalculator) :
|
public UserLevelCacheWriter() :
|
||||||
this(
|
this(
|
||||||
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
||||||
FileSystemWrapper.Default.File,
|
FileSystemWrapper.Default.File,
|
||||||
|
|
|
@ -88,15 +88,14 @@ namespace Microsoft.DotNet.Cli
|
||||||
var success = true;
|
var success = true;
|
||||||
var command = string.Empty;
|
var command = string.Empty;
|
||||||
var lastArg = 0;
|
var lastArg = 0;
|
||||||
var cliFallbackFolderPathCalculator = new CliFolderPathCalculator();
|
|
||||||
TopLevelCommandParserResult topLevelCommandParserResult = TopLevelCommandParserResult.Empty;
|
TopLevelCommandParserResult topLevelCommandParserResult = TopLevelCommandParserResult.Empty;
|
||||||
|
|
||||||
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel(cliFallbackFolderPathCalculator))
|
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel())
|
||||||
using (IFirstTimeUseNoticeSentinel disposableFirstTimeUseNoticeSentinel =
|
using (IFirstTimeUseNoticeSentinel disposableFirstTimeUseNoticeSentinel =
|
||||||
new FirstTimeUseNoticeSentinel(cliFallbackFolderPathCalculator))
|
new FirstTimeUseNoticeSentinel())
|
||||||
{
|
{
|
||||||
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel = disposableFirstTimeUseNoticeSentinel;
|
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel = disposableFirstTimeUseNoticeSentinel;
|
||||||
IAspNetCertificateSentinel aspNetCertificateSentinel = new AspNetCertificateSentinel(cliFallbackFolderPathCalculator);
|
IAspNetCertificateSentinel aspNetCertificateSentinel = new AspNetCertificateSentinel();
|
||||||
IFileSentinel toolPathSentinel = new FileSentinel(
|
IFileSentinel toolPathSentinel = new FileSentinel(
|
||||||
new FilePath(
|
new FilePath(
|
||||||
Path.Combine(
|
Path.Combine(
|
||||||
|
@ -174,7 +173,6 @@ namespace Microsoft.DotNet.Cli
|
||||||
firstTimeUseNoticeSentinel,
|
firstTimeUseNoticeSentinel,
|
||||||
aspNetCertificateSentinel,
|
aspNetCertificateSentinel,
|
||||||
toolPathSentinel,
|
toolPathSentinel,
|
||||||
cliFallbackFolderPathCalculator,
|
|
||||||
hasSuperUserAccess,
|
hasSuperUserAccess,
|
||||||
dotnetFirstRunConfiguration,
|
dotnetFirstRunConfiguration,
|
||||||
environmentProvider);
|
environmentProvider);
|
||||||
|
@ -241,7 +239,6 @@ namespace Microsoft.DotNet.Cli
|
||||||
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
||||||
IAspNetCertificateSentinel aspNetCertificateSentinel,
|
IAspNetCertificateSentinel aspNetCertificateSentinel,
|
||||||
IFileSentinel toolPathSentinel,
|
IFileSentinel toolPathSentinel,
|
||||||
CliFolderPathCalculator cliFolderPathCalculator,
|
|
||||||
bool hasSuperUserAccess,
|
bool hasSuperUserAccess,
|
||||||
DotnetFirstRunConfiguration dotnetFirstRunConfiguration,
|
DotnetFirstRunConfiguration dotnetFirstRunConfiguration,
|
||||||
IEnvironmentProvider environmentProvider)
|
IEnvironmentProvider environmentProvider)
|
||||||
|
@ -249,15 +246,11 @@ namespace Microsoft.DotNet.Cli
|
||||||
using (PerfTrace.Current.CaptureTiming())
|
using (PerfTrace.Current.CaptureTiming())
|
||||||
{
|
{
|
||||||
var nugetPackagesArchiver = new NuGetPackagesArchiver();
|
var nugetPackagesArchiver = new NuGetPackagesArchiver();
|
||||||
var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(
|
var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(hasSuperUserAccess, environmentProvider);
|
||||||
cliFolderPathCalculator,
|
|
||||||
hasSuperUserAccess,
|
|
||||||
environmentProvider);
|
|
||||||
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
|
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
|
||||||
var nugetCachePrimer = new NuGetCachePrimer(
|
var nugetCachePrimer = new NuGetCachePrimer(
|
||||||
nugetPackagesArchiver,
|
nugetPackagesArchiver,
|
||||||
nugetCacheSentinel,
|
nugetCacheSentinel);
|
||||||
cliFolderPathCalculator);
|
|
||||||
var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator();
|
var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator();
|
||||||
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||||
nugetCachePrimer,
|
nugetCachePrimer,
|
||||||
|
@ -268,7 +261,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
toolPathSentinel,
|
toolPathSentinel,
|
||||||
dotnetFirstRunConfiguration,
|
dotnetFirstRunConfiguration,
|
||||||
Reporter.Output,
|
Reporter.Output,
|
||||||
cliFolderPathCalculator.CliFallbackFolderPath,
|
CliFolderPathCalculator.CliFallbackFolderPath,
|
||||||
environmentPath);
|
environmentPath);
|
||||||
|
|
||||||
dotnetConfigurer.Configure();
|
dotnetConfigurer.Configure();
|
||||||
|
|
|
@ -14,15 +14,9 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
internal static class EnvironmentPathFactory
|
internal static class EnvironmentPathFactory
|
||||||
{
|
{
|
||||||
public static IEnvironmentPath CreateEnvironmentPath(
|
public static IEnvironmentPath CreateEnvironmentPath(
|
||||||
CliFolderPathCalculator cliFolderPathCalculator = null,
|
|
||||||
bool hasSuperUserAccess = false,
|
bool hasSuperUserAccess = false,
|
||||||
IEnvironmentProvider environmentProvider = null)
|
IEnvironmentProvider environmentProvider = null)
|
||||||
{
|
{
|
||||||
if (cliFolderPathCalculator == null)
|
|
||||||
{
|
|
||||||
cliFolderPathCalculator = new CliFolderPathCalculator();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (environmentProvider == null)
|
if (environmentProvider == null)
|
||||||
{
|
{
|
||||||
environmentProvider = new EnvironmentProvider();
|
environmentProvider = new EnvironmentProvider();
|
||||||
|
@ -32,14 +26,14 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
environmentPath = new WindowsEnvironmentPath(
|
environmentPath = new WindowsEnvironmentPath(
|
||||||
cliFolderPathCalculator.ToolsShimPath,
|
CliFolderPathCalculator.ToolsShimPath,
|
||||||
Reporter.Output,
|
Reporter.Output,
|
||||||
environmentProvider);
|
environmentProvider);
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && hasSuperUserAccess)
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && hasSuperUserAccess)
|
||||||
{
|
{
|
||||||
environmentPath = new LinuxEnvironmentPath(
|
environmentPath = new LinuxEnvironmentPath(
|
||||||
cliFolderPathCalculator.ToolsShimPathInUnix,
|
CliFolderPathCalculator.ToolsShimPathInUnix,
|
||||||
Reporter.Output,
|
Reporter.Output,
|
||||||
environmentProvider,
|
environmentProvider,
|
||||||
new FileWrapper());
|
new FileWrapper());
|
||||||
|
@ -47,7 +41,7 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && hasSuperUserAccess)
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && hasSuperUserAccess)
|
||||||
{
|
{
|
||||||
environmentPath = new OSXEnvironmentPath(
|
environmentPath = new OSXEnvironmentPath(
|
||||||
executablePath: cliFolderPathCalculator.ToolsShimPathInUnix,
|
executablePath: CliFolderPathCalculator.ToolsShimPathInUnix,
|
||||||
reporter: Reporter.Output,
|
reporter: Reporter.Output,
|
||||||
environmentProvider: environmentProvider,
|
environmentProvider: environmentProvider,
|
||||||
fileSystem: new FileWrapper());
|
fileSystem: new FileWrapper());
|
||||||
|
@ -57,10 +51,9 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnvironmentPathInstruction CreateEnvironmentPathInstruction(
|
public static IEnvironmentPathInstruction CreateEnvironmentPathInstruction(
|
||||||
CliFolderPathCalculator cliFolderPathCalculator = null,
|
|
||||||
IEnvironmentProvider environmentProvider = null)
|
IEnvironmentProvider environmentProvider = null)
|
||||||
{
|
{
|
||||||
return CreateEnvironmentPath(cliFolderPathCalculator, true, environmentProvider);
|
return CreateEnvironmentPath(true, environmentProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
|
|
||||||
private static DirectoryPath GetShimLocation()
|
private static DirectoryPath GetShimLocation()
|
||||||
{
|
{
|
||||||
var cliFolderPathCalculator = new CliFolderPathCalculator();
|
return new DirectoryPath(CliFolderPathCalculator.ToolsShimPath);
|
||||||
return new DirectoryPath(cliFolderPathCalculator.ToolsShimPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Cli.Telemetry
|
||||||
_hasher = hasher ?? Sha256Hasher.Hash;
|
_hasher = hasher ?? Sha256Hasher.Hash;
|
||||||
_getMACAddress = getMACAddress ?? MacAddressGetter.GetMacAddress;
|
_getMACAddress = getMACAddress ?? MacAddressGetter.GetMacAddress;
|
||||||
_dockerContainerDetector = dockerContainerDetector ?? new DockerContainerDetectorForTelemetry();
|
_dockerContainerDetector = dockerContainerDetector ?? new DockerContainerDetectorForTelemetry();
|
||||||
_userLevelCacheWriter = userLevelCacheWriter ?? new UserLevelCacheWriter(new CliFolderPathCalculator());
|
_userLevelCacheWriter = userLevelCacheWriter ?? new UserLevelCacheWriter();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IDockerContainerDetector _dockerContainerDetector;
|
private readonly IDockerContainerDetector _dockerContainerDetector;
|
||||||
|
|
|
@ -34,8 +34,7 @@ namespace Microsoft.DotNet.ToolPackage
|
||||||
|
|
||||||
private static DirectoryPath GetPackageLocation()
|
private static DirectoryPath GetPackageLocation()
|
||||||
{
|
{
|
||||||
var cliFolderPathCalculator = new CliFolderPathCalculator();
|
return new DirectoryPath(CliFolderPathCalculator.ToolsPackagePath);
|
||||||
return new DirectoryPath(cliFolderPathCalculator.ToolsPackagePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Microsoft.DotNet.ToolPackage
|
||||||
_store = store ?? throw new ArgumentNullException(nameof(store));
|
_store = store ?? throw new ArgumentNullException(nameof(store));
|
||||||
_projectRestorer = projectRestorer ?? throw new ArgumentNullException(nameof(projectRestorer));
|
_projectRestorer = projectRestorer ?? throw new ArgumentNullException(nameof(projectRestorer));
|
||||||
_tempProject = tempProject;
|
_tempProject = tempProject;
|
||||||
_offlineFeed = offlineFeed ?? new DirectoryPath(new CliFolderPathCalculator().CliFallbackFolderPath);
|
_offlineFeed = offlineFeed ?? new DirectoryPath(CliFolderPathCalculator.CliFallbackFolderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IToolPackage InstallPackage(PackageId packageId,
|
public IToolPackage InstallPackage(PackageId packageId,
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
||||||
public sealed class MSBuildLogger : INodeLogger
|
public sealed class MSBuildLogger : INodeLogger
|
||||||
{
|
{
|
||||||
private readonly IFirstTimeUseNoticeSentinel _sentinel =
|
private readonly IFirstTimeUseNoticeSentinel _sentinel =
|
||||||
new FirstTimeUseNoticeSentinel(new CliFolderPathCalculator());
|
new FirstTimeUseNoticeSentinel();
|
||||||
private readonly ITelemetry _telemetry;
|
private readonly ITelemetry _telemetry;
|
||||||
private const string NewEventName = "msbuild";
|
private const string NewEventName = "msbuild";
|
||||||
private const string TargetFrameworkTelemetryEventName = "targetframeworkeval";
|
private const string TargetFrameworkTelemetryEventName = "targetframeworkeval";
|
||||||
|
|
|
@ -31,8 +31,7 @@ namespace Microsoft.DotNet.Tools.New
|
||||||
{
|
{
|
||||||
var sessionId =
|
var sessionId =
|
||||||
Environment.GetEnvironmentVariable(MSBuildForwardingApp.TelemetrySessionIdEnvironmentVariableName);
|
Environment.GetEnvironmentVariable(MSBuildForwardingApp.TelemetrySessionIdEnvironmentVariableName);
|
||||||
var telemetry =
|
var telemetry = new Telemetry(new FirstTimeUseNoticeSentinel(), sessionId);
|
||||||
new Telemetry(new FirstTimeUseNoticeSentinel(new CliFolderPathCalculator()), sessionId);
|
|
||||||
var logger = new TelemetryLogger(null);
|
var logger = new TelemetryLogger(null);
|
||||||
|
|
||||||
if (telemetry.Enabled)
|
if (telemetry.Enabled)
|
||||||
|
|
|
@ -60,8 +60,6 @@ namespace Microsoft.DotNet.Tools.Tool.Install
|
||||||
_verbosity = appliedCommand.SingleArgumentOrDefault("verbosity");
|
_verbosity = appliedCommand.SingleArgumentOrDefault("verbosity");
|
||||||
_toolPath = appliedCommand.SingleArgumentOrDefault("tool-path");
|
_toolPath = appliedCommand.SingleArgumentOrDefault("tool-path");
|
||||||
|
|
||||||
var cliFolderPathCalculator = new CliFolderPathCalculator();
|
|
||||||
|
|
||||||
_createToolPackageStoreAndInstaller = createToolPackageStoreAndInstaller ?? ToolPackageFactory.CreateToolPackageStoreAndInstaller;
|
_createToolPackageStoreAndInstaller = createToolPackageStoreAndInstaller ?? ToolPackageFactory.CreateToolPackageStoreAndInstaller;
|
||||||
|
|
||||||
_environmentPathInstruction = environmentPathInstruction
|
_environmentPathInstruction = environmentPathInstruction
|
||||||
|
|
|
@ -34,8 +34,6 @@ namespace Microsoft.DotNet.Tools.Tool.Uninstall
|
||||||
IReporter reporter = null)
|
IReporter reporter = null)
|
||||||
: base(result)
|
: base(result)
|
||||||
{
|
{
|
||||||
var pathCalculator = new CliFolderPathCalculator();
|
|
||||||
|
|
||||||
_options = options ?? throw new ArgumentNullException(nameof(options));
|
_options = options ?? throw new ArgumentNullException(nameof(options));
|
||||||
_reporter = reporter ?? Reporter.Output;
|
_reporter = reporter ?? Reporter.Output;
|
||||||
_errorReporter = reporter ?? Reporter.Error;
|
_errorReporter = reporter ?? Reporter.Error;
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
|
|
||||||
private Mock<INuGetPackagesArchiver> _nugetPackagesArchiverMock;
|
private Mock<INuGetPackagesArchiver> _nugetPackagesArchiverMock;
|
||||||
private Mock<INuGetCacheSentinel> _nugetCacheSentinel;
|
private Mock<INuGetCacheSentinel> _nugetCacheSentinel;
|
||||||
private CliFolderPathCalculator _cliFolderPathCalculator;
|
|
||||||
|
|
||||||
public GivenANuGetCachePrimer()
|
public GivenANuGetCachePrimer()
|
||||||
{
|
{
|
||||||
|
@ -40,12 +39,9 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
|
|
||||||
_nugetCacheSentinel = new Mock<INuGetCacheSentinel>();
|
_nugetCacheSentinel = new Mock<INuGetCacheSentinel>();
|
||||||
|
|
||||||
_cliFolderPathCalculator = new CliFolderPathCalculator();
|
|
||||||
|
|
||||||
var nugetCachePrimer = new NuGetCachePrimer(
|
var nugetCachePrimer = new NuGetCachePrimer(
|
||||||
_nugetPackagesArchiverMock.Object,
|
_nugetPackagesArchiverMock.Object,
|
||||||
_nugetCacheSentinel.Object,
|
_nugetCacheSentinel.Object,
|
||||||
_cliFolderPathCalculator,
|
|
||||||
_fileSystemMock.File);
|
_fileSystemMock.File);
|
||||||
|
|
||||||
nugetCachePrimer.PrimeCache();
|
nugetCachePrimer.PrimeCache();
|
||||||
|
@ -63,7 +59,6 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
var nugetCachePrimer = new NuGetCachePrimer(
|
var nugetCachePrimer = new NuGetCachePrimer(
|
||||||
nugetPackagesArchiverMock.Object,
|
nugetPackagesArchiverMock.Object,
|
||||||
_nugetCacheSentinel.Object,
|
_nugetCacheSentinel.Object,
|
||||||
_cliFolderPathCalculator,
|
|
||||||
fileSystemMock.File);
|
fileSystemMock.File);
|
||||||
|
|
||||||
nugetCachePrimer.PrimeCache();
|
nugetCachePrimer.PrimeCache();
|
||||||
|
@ -75,7 +70,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
public void It_extracts_the_archive_to_the_fallback_folder()
|
public void It_extracts_the_archive_to_the_fallback_folder()
|
||||||
{
|
{
|
||||||
_nugetPackagesArchiverMock.Verify(n =>
|
_nugetPackagesArchiverMock.Verify(n =>
|
||||||
n.ExtractArchive(_cliFolderPathCalculator.CliFallbackFolderPath),
|
n.ExtractArchive(CliFolderPathCalculator.CliFallbackFolderPath),
|
||||||
Times.Exactly(1));
|
Times.Exactly(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +90,6 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
var nugetCachePrimer = new NuGetCachePrimer(
|
var nugetCachePrimer = new NuGetCachePrimer(
|
||||||
nugetPackagesArchiveMock.Object,
|
nugetPackagesArchiveMock.Object,
|
||||||
nugetCacheSentinel.Object,
|
nugetCacheSentinel.Object,
|
||||||
_cliFolderPathCalculator,
|
|
||||||
_fileSystemMock.File);
|
_fileSystemMock.File);
|
||||||
|
|
||||||
Action action = () => nugetCachePrimer.PrimeCache();
|
Action action = () => nugetCachePrimer.PrimeCache();
|
||||||
|
|
|
@ -15,9 +15,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
public void It_does_not_return_same_path_for_tools_package_and_tool_shim()
|
public void It_does_not_return_same_path_for_tools_package_and_tool_shim()
|
||||||
{
|
{
|
||||||
// shim name will conflict with the folder that is PackageId, if commandName and packageId are the same.
|
// shim name will conflict with the folder that is PackageId, if commandName and packageId are the same.
|
||||||
var cliFolderPathCalculator = new CliFolderPathCalculator();
|
CliFolderPathCalculator.ToolsPackagePath.Should().NotBe(CliFolderPathCalculator.ToolsShimPath);
|
||||||
cliFolderPathCalculator.ToolsPackagePath.Should().NotBe(cliFolderPathCalculator.ToolsShimPath);
|
CliFolderPathCalculator.ToolsPackagePath.Should().NotBe(CliFolderPathCalculator.ToolsShimPathInUnix.Path);
|
||||||
cliFolderPathCalculator.ToolsPackagePath.Should().NotBe(cliFolderPathCalculator.ToolsShimPathInUnix.Path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
|
|
||||||
File.Exists(profiled).Should().BeTrue();
|
File.Exists(profiled).Should().BeTrue();
|
||||||
File.ReadAllText(profiled).Should().Be(
|
File.ReadAllText(profiled).Should().Be(
|
||||||
$"export PATH=\"$PATH:{new CliFolderPathCalculator().ToolsShimPathInUnix.PathWithDollar}\"");
|
$"export PATH=\"$PATH:{CliFolderPathCalculator.ToolsShimPathInUnix.PathWithDollar}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
[MacOsOnlyFact]
|
[MacOsOnlyFact]
|
||||||
|
@ -234,7 +234,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
|
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
|
||||||
|
|
||||||
File.Exists(pathsd).Should().BeTrue();
|
File.Exists(pathsd).Should().BeTrue();
|
||||||
File.ReadAllText(pathsd).Should().Be(new CliFolderPathCalculator().ToolsShimPathInUnix.PathWithTilde);
|
File.ReadAllText(pathsd).Should().Be(CliFolderPathCalculator.ToolsShimPathInUnix.PathWithTilde);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue