Merge pull request #1208 from AustinWise/intrinsicInvoke

Invoke intrinsic commands directly instead of creating a process.
This commit is contained in:
David Fowler 2016-02-04 11:10:16 -08:00
commit d1b8eb9967
6 changed files with 28 additions and 55 deletions

View file

@ -280,13 +280,10 @@ namespace Microsoft.DotNet.Tools.Build
args.Add("--configuration");
args.Add(_args.ConfigValue);
args.Add(projectDependency.Project.ProjectDirectory);
var compileResult = Command.CreateDotNet("compile", args)
.ForwardStdOut()
.ForwardStdErr()
.Execute();
return compileResult.ExitCode == 0;
var compileResult = CommpileCommand.Run(args.ToArray());
return compileResult == 0;
}
private bool InvokeCompileOnRootProject()
@ -339,12 +336,9 @@ namespace Microsoft.DotNet.Tools.Build
args.Add(_rootProject.ProjectDirectory);
var compileResult = Command.CreateDotNet("compile", args)
.ForwardStdOut()
.ForwardStdErr()
.Execute();
var compileResult = CommpileCommand.Run(args.ToArray());
var succeeded = compileResult.ExitCode == 0;
var succeeded = compileResult == 0;
if (succeeded)
{

View file

@ -147,12 +147,9 @@ namespace Microsoft.DotNet.Tools.Compiler
// Need CoreRT Framework published to nuget
// Do Native Compilation
var result = Command.CreateDotNet("compile-native", new string[] { "--rsp", $"{rsp}" })
.ForwardStdErr()
.ForwardStdOut()
.Execute();
var result = Native.CompileNativeCommand.Run(new string[] { "--rsp", $"{rsp}" });
return result.ExitCode == 0;
return result == 0;
}
private static bool CompileProject(ProjectContext context, CompilerCommandApp args)
@ -378,13 +375,9 @@ namespace Microsoft.DotNet.Tools.Compiler
var rsp = Path.Combine(intermediateOutputPath, $"dotnet-resgen-resx.rsp");
File.WriteAllLines(rsp, arguments);
var result =
Command.CreateDotNet("resgen", new[] { $"@{rsp}" })
.ForwardStdErr()
.ForwardStdOut()
.Execute();
var result = Resgen.ResgenCommand.Run(new[] { $"@{rsp}" });
if (result.ExitCode != 0)
if (result != 0)
{
return false;
}
@ -429,11 +422,8 @@ namespace Microsoft.DotNet.Tools.Compiler
var rsp = Path.Combine(intermediateOutputPath, $"dotnet-resgen.rsp");
File.WriteAllLines(rsp, arguments);
var result = Command.CreateDotNet("resgen", new[] { $"@{rsp}" })
.ForwardStdErr()
.ForwardStdOut()
.Execute();
if (result.ExitCode != 0)
var result = Resgen.ResgenCommand.Run(new[] { $"@{rsp}" });
if (result != 0)
{
return false;
}

View file

@ -58,12 +58,9 @@ namespace Microsoft.DotNet.Tools.Pack
argsBuilder.Add($"{_project.ProjectFilePath}");
var result = Command.CreateDotNet("build", argsBuilder)
.ForwardStdOut()
.ForwardStdErr()
.Execute();
var result = Build.BuildCommand.Run(argsBuilder.ToArray());
return result.ExitCode;
return result;
}
return 0;

View file

@ -106,7 +106,7 @@ namespace Microsoft.DotNet.Tools.Publish
}
// Compile the project (and transitively, all it's dependencies)
var result = Command.CreateDotNet("build",
var result = Build.BuildCommand.Run(
new string[] {
"--framework",
$"{context.TargetFramework.DotNetFrameworkName}",
@ -115,12 +115,9 @@ namespace Microsoft.DotNet.Tools.Publish
"--configuration",
configuration,
context.ProjectFile.ProjectDirectory
})
.ForwardStdErr()
.ForwardStdOut()
.Execute();
});
if (result.ExitCode != 0)
if (result != 0)
{
return false;
}

View file

@ -52,14 +52,14 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
return context;
}
private static CommandResult CompileProject(ProjectContext projectContext, string configuration, out string tempOutputDir)
private static int CompileProject(ProjectContext projectContext, string configuration, out string tempOutputDir)
{
tempOutputDir = Path.Combine(projectContext.ProjectDirectory, "bin", ".dotnetrepl", Guid.NewGuid().ToString("N"));
Reporter.Output.WriteLine($"Compiling {projectContext.RootProject.Identity.Name.Yellow()} for {projectContext.TargetFramework.DotNetFrameworkName.Yellow()} to use with the {"C# REPL".Yellow()} environment.");
// --temp-output is actually the intermediate output folder and can be the same as --output for our temporary compilation (`dotnet run` can be seen doing the same)
return Command.CreateDotNet($"build", new []
return Build.BuildCommand.Run(new[]
{
$"--output",
$"{tempOutputDir}",
@ -70,10 +70,7 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
$"--configuration",
$"{configuration}",
$"{projectContext.ProjectDirectory}"
})
.ForwardStdOut(onlyIfVerbose: true)
.ForwardStdErr()
.Execute();
});
}
private static IEnumerable<string> GetRuntimeDependencies(ProjectContext projectContext, string buildConfiguration)
@ -151,10 +148,10 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
var compileResult = CompileProject(projectContext, buildConfiguration, out tempOutputDir);
if (compileResult.ExitCode != 0)
if (compileResult != 0)
{
Reporter.Error.WriteLine($"Project compilation failed. Exiting REPL".Red());
return compileResult.ExitCode;
return compileResult;
}
string responseFile = CreateResponseFile(projectContext, buildConfiguration, tempOutputDir);

View file

@ -90,7 +90,7 @@ namespace Microsoft.DotNet.Tools.Run
var tempDir = Path.Combine(_context.ProjectDirectory, "bin", ".dotnetrun", Guid.NewGuid().ToString("N"));
// Compile to that directory
var result = Command.CreateDotNet($"build", new []
var result = Build.BuildCommand.Run(new[]
{
$"--output",
$"{tempDir}",
@ -101,14 +101,11 @@ namespace Microsoft.DotNet.Tools.Run
$"--configuration",
$"{Configuration}",
$"{_context.ProjectFile.ProjectDirectory}"
})
.ForwardStdOut(onlyIfVerbose: true)
.ForwardStdErr()
.Execute();
});
if (result.ExitCode != 0)
if (result != 0)
{
return result.ExitCode;
return result;
}
// Now launch the output and give it the results
@ -149,7 +146,8 @@ namespace Microsoft.DotNet.Tools.Run
.ForwardStdOut()
.ForwardStdErr()
.EnvironmentVariable("DOTNET_HOME", dotnetHome)
.Execute();
.Execute()
.ExitCode;
// Clean up
if (!PreserveTemporary)
@ -157,7 +155,7 @@ namespace Microsoft.DotNet.Tools.Run
Directory.Delete(tempDir, recursive: true);
}
return result.ExitCode;
return result;
}
private static int RunInteractive(string scriptName)