Merge pull request #758 from tannergooding/ReplSeedProjectContext

Fixing up 'dotnet repl csharp' to load the correct output assemblies on Linux/Mac.
This commit is contained in:
Tanner Gooding 2016-01-08 20:59:55 -08:00
commit a9cf27c44d

View file

@ -97,7 +97,7 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
private static string CreateResponseFile(ProjectContext projectContext, string buildConfiguration, string tempOutputDir) private static string CreateResponseFile(ProjectContext projectContext, string buildConfiguration, string tempOutputDir)
{ {
var outputFileName = projectContext.ProjectFile.Name; var outputFileName = projectContext.ProjectFile.Name;
var outputFilePath = Path.Combine(tempOutputDir, $"{outputFileName}{Constants.DynamicLibSuffix}"); var outputFilePath = Path.Combine(tempOutputDir, $"{outputFileName}.dll");
var projectResponseFilePath = Path.Combine(tempOutputDir, $"dotnet-repl.{outputFileName}{Constants.ResponseFileSuffix}"); var projectResponseFilePath = Path.Combine(tempOutputDir, $"dotnet-repl.{outputFileName}{Constants.ResponseFileSuffix}");
var runtimeDependencies = GetRuntimeDependencies(projectContext, buildConfiguration); var runtimeDependencies = GetRuntimeDependencies(projectContext, buildConfiguration);
@ -120,9 +120,7 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
private static int Run(string script, string targetFramework, string buildConfiguration, bool preserveTemporaryOutput, string projectPath, IEnumerable<string> remainingArguments) private static int Run(string script, string targetFramework, string buildConfiguration, bool preserveTemporaryOutput, string projectPath, IEnumerable<string> remainingArguments)
{ {
var corerun = Path.Combine(AppContext.BaseDirectory, Constants.HostExecutableName); var csiArgs = new List<string>();
var csiExe = Path.Combine(AppContext.BaseDirectory, $"csi{Constants.ExeSuffix}");
var csiArgs = new StringBuilder();
if (buildConfiguration == null) if (buildConfiguration == null)
{ {
@ -150,24 +148,21 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
} }
string responseFile = CreateResponseFile(projectContext, buildConfiguration, tempOutputDir); string responseFile = CreateResponseFile(projectContext, buildConfiguration, tempOutputDir);
csiArgs.Append($"@\"{responseFile}\" "); csiArgs.Add($"@\"{responseFile}\"");
} }
if (string.IsNullOrEmpty(script) && !remainingArguments.Any()) if (string.IsNullOrEmpty(script) && !remainingArguments.Any())
{ {
csiArgs.Append("-i"); csiArgs.Add("-i");
} }
else else
{ {
csiArgs.Append(script); csiArgs.Add(script);
} }
foreach (string remainingArgument in remainingArguments) csiArgs.AddRange(remainingArguments);
{
csiArgs.Append($" {remainingArgument}");
}
return Command.Create(csiExe, csiArgs.ToString()) return Command.Create("csi", csiArgs)
.ForwardStdOut() .ForwardStdOut()
.ForwardStdErr() .ForwardStdErr()
.Execute() .Execute()