8000 Merge branch 'master' into eval-stdin · dotnet-script/dotnet-script@92dd444 · GitHub
[go: up one dir, main page]

Skip to content

Commit 92dd444

Browse files
authored
Merge branch 'master' into eval-stdin
2 parents c9df234 + c4e0d8b commit 92dd444

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ In order to execute a script it needs to be compiled first and since that is a C
264264

265265
> You can override this automatic caching by passing **--no-cache** flag, which will bypass both caches and cause dependency resolution and script compilation to happen every time we execute the script.
266266
267+
#### Cache Location
268+
269+
The temporary location used for caches is a sub-directory named `dotnet-script` under (in order of priority):
270+
271+
1. The path specified for the value of the environment variable named `DOTNET_SCRIPT_CACHE_LOCATION`, if defined and value is not empty.
272+
2. Linux distributions only: `$XDG_CACHE_HOME` if defined otherwise `$HOME/.cache`
273+
3. macOS only: `~/Library/Caches`
274+
4. The value returned by [`Path.GetTempPath`](https://docs.microsoft.com/en-us/dotnet/api/system.io.path.gettemppath) for the platform.
275+
267276
###
268277

269278
### Debugging

src/Dotnet.Script.Core/Commands/ExecuteScriptCommand.cs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,20 @@ private string GetLibrary(ExecuteScriptCommandOptions executeOptions)
4949
var executionCacheFolder = Path.Combine(projectFolder, "execution-cache");
5050
var pathToLibrary = Path.Combine(executionCacheFolder, "script.dll");
5151

52-
if (!TryCreateHash(executeOptions, out var hash) || !TryGetHash(executionCacheFolder, out var cachedHash))
52+
if (TryCreateHash(executeOptions, out var hash)
53+
&& TryGetHash(executionCacheFolder, out var cachedHash)
54+
&& string.Equals(hash, cachedHash))
5355
{
54-
return CreateLibrary();
56+
return pathToLibrary;
5557
}
5658

57-
if (!string.Equals(hash, cachedHash))
59+
var options = new PublishCommandOptions(executeOptions.File, executionCacheFolder, "script", PublishType.Library, executeOptions.OptimizationLevel, executeOptions.PackageSources, null, executeOptions.NoCache);
60+
new PublishCommand(_scriptConsole, _logFactory).Execute(options);
61+
if (hash != null)
5862
{
59-
return CreateLibrary();
60-
}
61-
62-
return pathToLibrary;
63-
64-
string CreateLibrary()
65-
{
66-
var options = new PublishCommandOptions(executeOptions.File, executionCacheFolder, "script", PublishType.Library, executeOptions.OptimizationLevel, executeOptions.PackageSources, null, executeOptions.NoCache);
67-
new PublishCommand(_scriptConsole, _logFactory).Execute(options);
68-
if (hash != null)
69-
{
70-
File.WriteAllText(Path.Combine(executionCacheFolder, "script.sha256"), hash);
71-
}
72-
return Path.Combine(executionCacheFolder, "script.dll");
63+
File.WriteAllText(Path.Combine(executionCacheFolder, "script.sha256"), hash);
7364
}
65+
return Path.Combine(executionCacheFolder, "script.dll");
7466
}
7567

7668
public bool TryCreateHash(ExecuteScriptCommandOptions options, out string hash)

0 commit comments

Comments
 (0)
0