Skip to content

Commit 1eb38e6

Browse files
committed
Merge branch 'master' into macos-arm64
2 parents 0cfc23e + 6422290 commit 1eb38e6

30 files changed

+250
-114
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public async Task<TReturn> Execute<TReturn>(ExecuteCodeCommandOptions options)
2222
{
2323
var sourceText = SourceText.From(options.Code);
2424
var context = new ScriptContext(sourceText, options.WorkingDirectory ?? Directory.GetCurrentDirectory(), options.Arguments, null, options.OptimizationLevel, ScriptMode.Eval, options.PackageSources);
25-
var compiler = new ScriptCompiler(_logFactory, !options.NoCache)
25+
var compiler = new ScriptCompiler(_logFactory, options.CachePath, !options.NoCache)
2626
{
2727
#if NETCOREAPP
2828
AssemblyLoadContext = options.AssemblyLoadContext

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ namespace Dotnet.Script.Core.Commands
77
{
88
public class ExecuteCodeCommandOptions
99
{
10-
public ExecuteCodeCommandOptions(string code, string workingDirectory, string[] arguments, OptimizationLevel optimizationLevel, bool noCache, string[] packageSources)
10+
public ExecuteCodeCommandOptions(string code, string workingDirectory, string[] arguments, OptimizationLevel optimizationLevel, string cachePath, bool noCache, string[] packageSources)
1111
{
1212
Code = code;
1313
WorkingDirectory = workingDirectory;
1414
Arguments = arguments;
1515
OptimizationLevel = optimizationLevel;
16+
CachePath = cachePath;
1617
NoCache = noCache;
1718
PackageSources = packageSources;
1819
}
@@ -21,6 +22,7 @@ public ExecuteCodeCommandOptions(string code, string workingDirectory, string[]
2122
public string WorkingDirectory { get; }
2223
public string[] Arguments { get; }
2324
public OptimizationLevel OptimizationLevel { get; }
25+
public string CachePath { get; }
2426
public bool NoCache { get; }
2527
public string[] PackageSources { get; }
2628

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public ExecuteInteractiveCommand(ScriptConsole scriptConsole, LogFactory logFact
1818

1919
public async Task<int> Execute(ExecuteInteractiveCommandOptions options)
2020
{
21-
var compiler = new ScriptCompiler(_logFactory, useRestoreCache: false)
21+
var compiler = new ScriptCompiler(_logFactory, options.CachePath, useRestoreCache: false)
2222
{
2323
#if NETCOREAPP
2424
AssemblyLoadContext = options.AssemblyLoadContext

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ namespace Dotnet.Script.Core.Commands
66
{
77
public class ExecuteInteractiveCommandOptions
88
{
9-
public ExecuteInteractiveCommandOptions(ScriptFile scriptFile, string[] arguments, string[] packageSources)
9+
public ExecuteInteractiveCommandOptions(ScriptFile scriptFile, string[] arguments, string[] packageSources, string cachePath)
1010
{
1111
ScriptFile = scriptFile;
1212
Arguments = arguments;
1313
PackageSources = packageSources;
14+
CachePath = cachePath;
1415
}
1516

1617
public ScriptFile ScriptFile { get; }
1718
public string[] Arguments { get; }
1819
public string[] PackageSources { get; }
20+
public string CachePath { get; }
1921

2022
#if NETCOREAPP
2123
#nullable enable

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public async Task<TReturn> Execute<TReturn>(ExecuteLibraryCommandOptions options
2525
}
2626

2727
var absoluteFilePath = options.LibraryPath.GetRootedPath();
28-
var compiler = new ScriptCompiler(_logFactory, !options.NoCache)
28+
var compiler = new ScriptCompiler(_logFactory, options.CachePath, !options.NoCache)
2929
{
3030
#if NETCOREAPP
3131
AssemblyLoadContext = options.AssemblyLoadContext

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ namespace Dotnet.Script.Core.Commands
66
{
77
public class ExecuteLibraryCommandOptions
88
{
9-
public ExecuteLibraryCommandOptions(string libraryPath, string[] arguments, bool noCache)
9+
public ExecuteLibraryCommandOptions(string libraryPath, string[] arguments, string cachePath, bool noCache)
1010
{
1111
LibraryPath = libraryPath;
1212
Arguments = arguments;
13+
CachePath = cachePath;
1314
NoCache = noCache;
1415
}
1516

1617
public string LibraryPath { get; }
1718
public string[] Arguments { get; }
19+
public string CachePath { get; }
1820
public bool NoCache { get; }
1921

2022
#if NETCOREAPP

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public async Task<TReturn> Run<TReturn, THost>(ExecuteScriptCommandOptions optio
3333

3434
var pathToLibrary = GetLibrary<TReturn>(options);
3535

36-
var libraryOptions = new ExecuteLibraryCommandOptions(pathToLibrary, options.Arguments, options.NoCache)
36+
var libraryOptions = new ExecuteLibraryCommandOptions(pathToLibrary, options.Arguments, options.CachePath, options.NoCache)
3737
{
3838
#if NETCOREAPP
3939
AssemblyLoadContext = options.AssemblyLoadContext
@@ -46,13 +46,13 @@ private async Task<TReturn> DownloadAndRunCode<TReturn>(ExecuteScriptCommandOpti
4646
{
4747
var downloader = new ScriptDownloader();
4848
var code = await downloader.Download(executeOptions.File.Path);
49-
var options = new ExecuteCodeCommandOptions(code, Directory.GetCurrentDirectory(), executeOptions.Arguments, executeOptions.OptimizationLevel, executeOptions.NoCache, executeOptions.PackageSources);
49+
var options = new ExecuteCodeCommandOptions(code, Directory.GetCurrentDirectory(), executeOptions.Arguments, executeOptions.OptimizationLevel, executeOptions.CachePath, executeOptions.NoCache, executeOptions.PackageSources);
5050
return await new ExecuteCodeCommand(_scriptConsole, _logFactory).Execute<TReturn>(options);
5151
}
5252

5353
private string GetLibrary<TReturn>(ExecuteScriptCommandOptions executeOptions)
5454
{
55-
var projectFolder = FileUtils.GetPathToScriptTempFolder(executeOptions.File.Path);
55+
var projectFolder = FileUtils.GetPathToScriptTempFolder(executeOptions.File.Path, executeOptions.CachePath);
5656
var executionCacheFolder = Path.Combine(projectFolder, "execution-cache");
5757
var pathToLibrary = Path.Combine(executionCacheFolder, "script.dll");
5858

@@ -64,7 +64,7 @@ private string GetLibrary<TReturn>(ExecuteScriptCommandOptions executeOptions)
6464
return pathToLibrary;
6565
}
6666

67-
var options = new PublishCommandOptions(executeOptions.File, executionCacheFolder, "script", PublishType.Library, executeOptions.OptimizationLevel, executeOptions.PackageSources, null, executeOptions.NoCache)
67+
var options = new PublishCommandOptions(executeOptions.File, executionCacheFolder, "script", PublishType.Library, executeOptions.OptimizationLevel, executeOptions.PackageSources, null, executeOptions.CachePath, executeOptions.NoCache)
6868
{
6969
#if NETCOREAPP
7070
AssemblyLoadContext = executeOptions.AssemblyLoadContext
@@ -89,7 +89,7 @@ public bool TryCreateHash(ExecuteScriptCommandOptions options, out string hash)
8989

9090
var scriptFilesProvider = new ScriptFilesResolver();
9191
var allScriptFiles = scriptFilesProvider.GetScriptFiles(options.File.Path);
92-
var projectFile = new ScriptProjectProvider(_logFactory).CreateProjectFileFromScriptFiles(ScriptEnvironment.Default.TargetFramework, allScriptFiles.ToArray());
92+
var projectFile = new ScriptProjectProvider(_logFactory, options.CachePath).CreateProjectFileFromScriptFiles(ScriptEnvironment.Default.TargetFramework, allScriptFiles.ToArray());
9393

9494
if (!projectFile.IsCacheable)
9595
{

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ namespace Dotnet.Script.Core.Commands
77
{
88
public class ExecuteScriptCommandOptions
99
{
10-
public ExecuteScriptCommandOptions(ScriptFile file, string[] arguments, OptimizationLevel optimizationLevel, string[] packageSources, bool isInteractive ,bool noCache)
10+
public ExecuteScriptCommandOptions(ScriptFile file, string[] arguments, OptimizationLevel optimizationLevel, string[] packageSources, bool isInteractive, string cachePath, bool noCache)
1111
{
1212
File = file;
1313
Arguments = arguments;
1414
OptimizationLevel = optimizationLevel;
1515
PackageSources = packageSources;
1616
IsInteractive = isInteractive;
17+
CachePath = cachePath;
1718
NoCache = noCache;
1819
}
1920

@@ -22,6 +23,7 @@ public ExecuteScriptCommandOptions(ScriptFile file, string[] arguments, Optimiza
2223
public OptimizationLevel OptimizationLevel { get; }
2324
public string[] PackageSources { get; }
2425
public bool IsInteractive { get; }
26+
public string CachePath { get; }
2527
public bool NoCache { get; }
2628

2729
#if NETCOREAPP

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public void Execute<TReturn>(PublishCommandOptions options)
3333
(options.PublishType == PublishType.Library ? Path.Combine(Path.GetDirectoryName(absoluteFilePath), "publish") : Path.Combine(Path.GetDirectoryName(absoluteFilePath), "publish", options.RuntimeIdentifier));
3434

3535
var absolutePublishDirectory = publishDirectory.GetRootedPath();
36-
var compiler = new ScriptCompiler(_logFactory, !options.NoCache)
36+
var compiler = new ScriptCompiler(_logFactory, options.CachePath, !options.NoCache)
3737
{
3838
#if NETCOREAPP
3939
AssemblyLoadContext = options.AssemblyLoadContext
4040
#endif
4141
};
4242
var scriptEmitter = new ScriptEmitter(_scriptConsole, compiler);
43-
var publisher = new ScriptPublisher(_logFactory, scriptEmitter);
43+
var publisher = new ScriptPublisher(_logFactory, scriptEmitter, options.CachePath);
4444
var code = absoluteFilePath.ToSourceText();
4545
var context = new ScriptContext(code, absolutePublishDirectory, Enumerable.Empty<string>(), absoluteFilePath, options.OptimizationLevel, packageSources: options.PackageSources);
4646

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Dotnet.Script.Core.Commands
88
{
99
public class PublishCommandOptions
1010
{
11-
public PublishCommandOptions(ScriptFile file, string outputDirectory, string libraryName, PublishType publishType, OptimizationLevel optimizationLevel, string[] packageSources, string runtimeIdentifier, bool noCache)
11+
public PublishCommandOptions(ScriptFile file, string outputDirectory, string libraryName, PublishType publishType, OptimizationLevel optimizationLevel, string[] packageSources, string runtimeIdentifier, string cachePath, bool noCache)
1212
{
1313
File = file;
1414
OutputDirectory = outputDirectory;
@@ -17,6 +17,7 @@ public PublishCommandOptions(ScriptFile file, string outputDirectory, string lib
1717
OptimizationLevel = optimizationLevel;
1818
PackageSources = packageSources;
1919
RuntimeIdentifier = runtimeIdentifier ?? ScriptEnvironment.Default.RuntimeIdentifier;
20+
CachePath = cachePath;
2021
NoCache = noCache;
2122
}
2223

@@ -27,6 +28,7 @@ public PublishCommandOptions(ScriptFile file, string outputDirectory, string lib
2728
public OptimizationLevel OptimizationLevel { get; }
2829
public string[] PackageSources { get; }
2930
public string RuntimeIdentifier { get; }
31+
public string CachePath { get; }
3032
public bool NoCache { get; }
3133

3234
#if NETCOREAPP

0 commit comments

Comments
 (0)