Fixing the location of the sentinel and placing it side by side with the fallback folder.

This commit is contained in:
Livar Cunha 2017-03-30 14:14:36 -07:00
parent 0c1af8a2fe
commit 347bd4b1fe
3 changed files with 27 additions and 39 deletions

View file

@ -17,25 +17,13 @@ namespace Microsoft.DotNet.Configurer
private string _nugetCachePath; private string _nugetCachePath;
private string NuGetCachePath private string SentinelPath => Path.Combine(_nugetCachePath, SENTINEL);
{ private string InProgressSentinelPath => Path.Combine(_nugetCachePath, INPROGRESS_SENTINEL);
get
{
if (string.IsNullOrEmpty(_nugetCachePath))
{
_nugetCachePath = NuGetPathContext.Create(new NullSettings()).UserPackageFolder;
}
return _nugetCachePath;
}
}
private string SentinelPath => Path.Combine(NuGetCachePath, SENTINEL);
private string InProgressSentinelPath => Path.Combine(NuGetCachePath, INPROGRESS_SENTINEL);
private Stream InProgressSentinel { get; set; } private Stream InProgressSentinel { get; set; }
public NuGetCacheSentinel() : this(string.Empty, FileSystemWrapper.Default.File) public NuGetCacheSentinel(CLIFallbackFolderPathCalculator cliFallbackFolderPathCalculator) :
this(cliFallbackFolderPathCalculator.CLIFallbackFolderPath, FileSystemWrapper.Default.File)
{ {
} }
@ -74,9 +62,9 @@ namespace Microsoft.DotNet.Configurer
{ {
try try
{ {
if(!Directory.Exists(NuGetCachePath)) if(!Directory.Exists(_nugetCachePath))
{ {
Directory.CreateDirectory(NuGetCachePath); Directory.CreateDirectory(_nugetCachePath);
} }
// open an exclusive handle to the in-progress sentinel and mark it for delete on close. // open an exclusive handle to the in-progress sentinel and mark it for delete on close.

View file

@ -79,7 +79,8 @@ namespace Microsoft.DotNet.Cli
var success = true; var success = true;
var command = string.Empty; var command = string.Empty;
var lastArg = 0; var lastArg = 0;
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel()) var cliFallbackFolderPathCalculator = new CLIFallbackFolderPathCalculator();
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel(cliFallbackFolderPathCalculator))
{ {
for (; lastArg < args.Length; lastArg++) for (; lastArg < args.Length; lastArg++)
{ {
@ -111,7 +112,7 @@ namespace Microsoft.DotNet.Cli
} }
else else
{ {
ConfigureDotNetForFirstTimeUse(nugetCacheSentinel); ConfigureDotNetForFirstTimeUse(nugetCacheSentinel, cliFallbackFolderPathCalculator);
// It's the command, and we're done! // It's the command, and we're done!
command = args[lastArg]; command = args[lastArg];
@ -165,28 +166,27 @@ namespace Microsoft.DotNet.Cli
} }
private static void ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel) private static void ConfigureDotNetForFirstTimeUse(
INuGetCacheSentinel nugetCacheSentinel,
CLIFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
{ {
using (PerfTrace.Current.CaptureTiming()) using (PerfTrace.Current.CaptureTiming())
{ {
using (var nugetPackagesArchiver = new NuGetPackagesArchiver()) var nugetPackagesArchiver = new NuGetPackagesArchiver();
{ var environmentProvider = new EnvironmentProvider();
var cliFallbackFolderPathCalculator = new CLIFallbackFolderPathCalculator(); var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
var environmentProvider = new EnvironmentProvider(); var nugetConfig = new NuGetConfig(cliFallbackFolderPathCalculator);
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true); var nugetCachePrimer = new NuGetCachePrimer(
var nugetConfig = new NuGetConfi(cliFallbackFolderPathCalculator); nugetPackagesArchiver,
var nugetCachePrimer = new NuGetCachePrimer( nugetCacheSentinel,
nugetPackagesArchiver, nugetConfig,
nugetCacheSentinel, cliFallbackFolderPathCalculator);
nugetConfig, var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
cliFallbackFolderPathCalculator); nugetCachePrimer,
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer( nugetCacheSentinel,
nugetCachePrimer, environmentProvider);
nugetCacheSentinel,
environmentProvider);
dotnetConfigurer.Configure(); dotnetConfigurer.Configure();
}
} }
} }

View file

@ -11,7 +11,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
{ {
public sealed class MSBuildLogger : Logger public sealed class MSBuildLogger : Logger
{ {
private readonly INuGetCacheSentinel _sentinel = new NuGetCacheSentinel(); private readonly INuGetCacheSentinel _sentinel = new NuGetCacheSentinel(new CLIFallbackFolderPathCalculator());
private readonly ITelemetry _telemetry; private readonly ITelemetry _telemetry;
public MSBuildLogger() public MSBuildLogger()