From 38737326f2fe3c779f8373f1bca1a35fd2d36b26 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 6 Jun 2020 15:38:24 +0200 Subject: [PATCH 1/2] Add cache info to "--info" mode --- .../Versioning/EnvironmentReporter.cs | 11 +++++++++-- .../ProjectSystem/FileUtils.cs | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs b/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs index b641a727..be86977b 100644 --- a/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs +++ b/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs @@ -1,10 +1,12 @@ using System.Text; using System.Threading.Tasks; +using Dotnet.Script.DependencyModel.ProjectSystem; using Dotnet.Script.DependencyModel.Environment; using Dotnet.Script.DependencyModel.Logging; namespace Dotnet.Script.Core.Versioning { + /// /// A class that reports environmental information to the . /// @@ -47,14 +49,16 @@ public async Task ReportInfo() var currentVersion = _versionProvider.GetCurrentVersion(); var latestVersion = await _versionProvider.GetLatestVersion(); - ReportEnvironmentalInfo(currentVersion); + ReportEnvironmentalInfo(currentVersion, + $"Scripts temp path : {FileUtils.GetScriptsTempPath()}"); if (!latestVersion.Equals(currentVersion) && latestVersion.IsResolved) { ReportThatNewVersionIsAvailable(latestVersion); } } - private void ReportEnvironmentalInfo(VersionInfo installedVersion) + private void ReportEnvironmentalInfo(VersionInfo installedVersion, + params string[] footers) { var netCoreVersion = _scriptEnvironment.NetCoreVersion; @@ -66,6 +70,9 @@ private void ReportEnvironmentalInfo(VersionInfo installedVersion) sb.AppendLine($"Platform identifier : {ScriptEnvironment.Default.PlatformIdentifier}"); sb.AppendLine($"Runtime identifier : {ScriptEnvironment.Default.RuntimeIdentifier}"); + foreach (var footer in footers) + sb.AppendLine(footer); + _scriptConsole.WriteNormal(sb.ToString()); } diff --git a/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs b/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs index aa52c14a..350b39bd 100644 --- a/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs +++ b/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs @@ -22,6 +22,9 @@ public static string CreateTempFolder(string targetDirectory, string targetFrame return pathToProjectDirectory; } + public static string GetScriptsTempPath() => + Path.Combine(GetTempPath(), "dotnet-script"); + public static string GetPathToScriptTempFolder(string targetDirectory) { if (!Path.IsPathRooted(targetDirectory)) @@ -29,7 +32,6 @@ public static string GetPathToScriptTempFolder(string targetDirectory) throw new ArgumentOutOfRangeException(nameof(targetDirectory), "Must be a root path"); } - var tempDirectory = GetTempPath(); var pathRoot = Path.GetPathRoot(targetDirectory); var targetDirectoryWithoutRoot = targetDirectory.Substring(pathRoot.Length); if (pathRoot.Length > 0 && ScriptEnvironment.Default.IsWindows) @@ -43,7 +45,7 @@ public static string GetPathToScriptTempFolder(string targetDirectory) targetDirectoryWithoutRoot = Path.Combine(driveLetter, targetDirectoryWithoutRoot); } - var pathToProjectDirectory = Path.Combine(tempDirectory, "dotnet-script", targetDirectoryWithoutRoot); + var pathToProjectDirectory = Path.Combine(GetScriptsTempPath(), targetDirectoryWithoutRoot); return pathToProjectDirectory; } From 8c67160d3713b0bfa74d65d0593fbda5f79544f3 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Tue, 9 Jun 2020 22:17:39 +0200 Subject: [PATCH 2/2] Log when running from cache --- .../Commands/ExecuteScriptCommand.cs | 1 + .../Versioning/EnvironmentReporter.cs | 11 ++--------- .../ProjectSystem/FileUtils.cs | 6 ++---- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Dotnet.Script.Core/Commands/ExecuteScriptCommand.cs b/src/Dotnet.Script.Core/Commands/ExecuteScriptCommand.cs index 747f6252..6bf3809c 100644 --- a/src/Dotnet.Script.Core/Commands/ExecuteScriptCommand.cs +++ b/src/Dotnet.Script.Core/Commands/ExecuteScriptCommand.cs @@ -53,6 +53,7 @@ private string GetLibrary(ExecuteScriptCommandOptions executeOptions) && TryGetHash(executionCacheFolder, out var cachedHash) && string.Equals(hash, cachedHash)) { + _logger.Debug($"Using cached compilation: " + pathToLibrary); return pathToLibrary; } diff --git a/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs b/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs index be86977b..b641a727 100644 --- a/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs +++ b/src/Dotnet.Script.Core/Versioning/EnvironmentReporter.cs @@ -1,12 +1,10 @@ using System.Text; using System.Threading.Tasks; -using Dotnet.Script.DependencyModel.ProjectSystem; using Dotnet.Script.DependencyModel.Environment; using Dotnet.Script.DependencyModel.Logging; namespace Dotnet.Script.Core.Versioning { - /// /// A class that reports environmental information to the . /// @@ -49,16 +47,14 @@ public async Task ReportInfo() var currentVersion = _versionProvider.GetCurrentVersion(); var latestVersion = await _versionProvider.GetLatestVersion(); - ReportEnvironmentalInfo(currentVersion, - $"Scripts temp path : {FileUtils.GetScriptsTempPath()}"); + ReportEnvironmentalInfo(currentVersion); if (!latestVersion.Equals(currentVersion) && latestVersion.IsResolved) { ReportThatNewVersionIsAvailable(latestVersion); } } - private void ReportEnvironmentalInfo(VersionInfo installedVersion, - params string[] footers) + private void ReportEnvironmentalInfo(VersionInfo installedVersion) { var netCoreVersion = _scriptEnvironment.NetCoreVersion; @@ -70,9 +66,6 @@ private void ReportEnvironmentalInfo(VersionInfo installedVersion, sb.AppendLine($"Platform identifier : {ScriptEnvironment.Default.PlatformIdentifier}"); sb.AppendLine($"Runtime identifier : {ScriptEnvironment.Default.RuntimeIdentifier}"); - foreach (var footer in footers) - sb.AppendLine(footer); - _scriptConsole.WriteNormal(sb.ToString()); } diff --git a/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs b/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs index 350b39bd..aa52c14a 100644 --- a/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs +++ b/src/Dotnet.Script.DependencyModel/ProjectSystem/FileUtils.cs @@ -22,9 +22,6 @@ public static string CreateTempFolder(string targetDirectory, string targetFrame return pathToProjectDirectory; } - public static string GetScriptsTempPath() => - Path.Combine(GetTempPath(), "dotnet-script"); - public static string GetPathToScriptTempFolder(string targetDirectory) { if (!Path.IsPathRooted(targetDirectory)) @@ -32,6 +29,7 @@ public static string GetPathToScriptTempFolder(string targetDirectory) throw new ArgumentOutOfRangeException(nameof(targetDirectory), "Must be a root path"); } + var tempDirectory = GetTempPath(); var pathRoot = Path.GetPathRoot(targetDirectory); var targetDirectoryWithoutRoot = targetDirectory.Substring(pathRoot.Length); if (pathRoot.Length > 0 && ScriptEnvironment.Default.IsWindows) @@ -45,7 +43,7 @@ public static string GetPathToScriptTempFolder(string targetDirectory) targetDirectoryWithoutRoot = Path.Combine(driveLetter, targetDirectoryWithoutRoot); } - var pathToProjectDirectory = Path.Combine(GetScriptsTempPath(), targetDirectoryWithoutRoot); + var pathToProjectDirectory = Path.Combine(tempDirectory, "dotnet-script", targetDirectoryWithoutRoot); return pathToProjectDirectory; }