Product Changes to Work with new argument escaping

This commit is contained in:
Bryan 2016-01-22 14:04:04 -08:00 committed by Bryan Thornbury
parent e794ad6a10
commit 8d0fada156
20 changed files with 318 additions and 257 deletions

View file

@ -119,7 +119,7 @@ Common Commands:
{ {
if (appArgs.Any()) if (appArgs.Any())
{ {
return Command.Create("dotnet-" + appArgs.First(), "--help") return Command.Create("dotnet-" + appArgs.First(), new string[] { "--help" })
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute() .Execute()

View file

@ -6,16 +6,16 @@
}, },
"dependencies": { "dependencies": {
"NETStandard.Library": "1.0.0-rc2-23704", "NETStandard.Library": "1.0.0-rc2-23704",
"System.Threading.ThreadPool": "4.0.10-beta-23704", "System.Threading.ThreadPool": "4.0.10-rc2-23704",
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23704", "System.Runtime.Serialization.Primitives": "4.1.0-rc2-23704",
"Microsoft.DotNet.ProjectModel": "1.0.0-*", "Microsoft.DotNet.ProjectModel": {"target":"project"},
"Microsoft.DotNet.Compiler.Common": "1.0.0-*", "Microsoft.DotNet.Compiler.Common": {"target":"project"},
"Microsoft.Extensions.CommandLineUtils.Sources": { "Microsoft.Extensions.CommandLineUtils.Sources": {
"type": "build", "type": "build",
"version": "1.0.0-*" "version": "1.0.0-*"
}, },
"Microsoft.Extensions.Logging": "1.0.0-rc2-15935", "Microsoft.Extensions.Logging": "1.0.0-rc2-16011",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-15935", "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-16011",
"Newtonsoft.Json": "7.0.1" "Newtonsoft.Json": "7.0.1"
}, },
"frameworks": { "frameworks": {

View file

@ -13,7 +13,7 @@
"System.Xml.XDocument": "4.0.11-rc2-23704", "System.Xml.XDocument": "4.0.11-rc2-23704",
"NuGet.Packaging": "3.4.0-beta-*", "NuGet.Packaging": "3.4.0-beta-*",
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15964", "Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15975",
"Microsoft.Extensions.JsonParser.Sources": { "Microsoft.Extensions.JsonParser.Sources": {
"type": "build", "type": "build",
"version": "1.0.0-*" "version": "1.0.0-*"

View file

@ -220,7 +220,7 @@ namespace Microsoft.DotNet.Tools.Build
private void CollectCheckPathProbingPreconditions(ProjectContext project, IncrementalPreconditions preconditions) private void CollectCheckPathProbingPreconditions(ProjectContext project, IncrementalPreconditions preconditions)
{ {
var pathCommands = CompilerUtil.GetCommandsInvokedByCompile(project) var pathCommands = CompilerUtil.GetCommandsInvokedByCompile(project)
.Select(commandName => Command.Create(commandName, "", project.TargetFramework)) .Select(commandName => Command.Create(commandName, new string[] { }, project.TargetFramework))
.Where(c => c.ResolutionStrategy.Equals(CommandResolutionStrategy.Path)); .Where(c => c.ResolutionStrategy.Equals(CommandResolutionStrategy.Path));
foreach (var pathCommand in pathCommands) foreach (var pathCommand in pathCommands)
@ -257,13 +257,40 @@ namespace Microsoft.DotNet.Tools.Build
private bool InvokeCompileOnDependency(ProjectDescription projectDependency) private bool InvokeCompileOnDependency(ProjectDescription projectDependency)
{ {
var compileResult = Command.Create("dotnet-compile", string[] args;
$"--framework {projectDependency.Framework} " + if (_args.NoHostValue)
$"--configuration {_args.ConfigValue} " + {
$"--output \"{_args.OutputValue}\" " + args = new string[]
$"--temp-output \"{_args.IntermediateValue}\" " + {
(_args.NoHostValue ? "--no-host " : string.Empty) + $"--framework",
$"\"{projectDependency.Project.ProjectDirectory}\"") $"{projectDependency.Framework}",
$"--configuration",
$"{_args.ConfigValue}",
$"--output",
$"{_args.OutputValue}",
$"--temp-output",
$"{_args.IntermediateValue}",
"--no-host",
$"{projectDependency.Project.ProjectDirectory}"
};
}
else
{
args = new string[]
{
$"--framework",
$"{projectDependency.Framework}",
$"--configuration",
$"{_args.ConfigValue}",
$"--output",
$"{_args.OutputValue}",
$"--temp-output",
$"{_args.IntermediateValue}",
$"{projectDependency.Project.ProjectDirectory}"
};
}
var compileResult = Command.Create("dotnet-compile", args)
.ForwardStdOut() .ForwardStdOut()
.ForwardStdErr() .ForwardStdErr()
.Execute(); .Execute();
@ -274,20 +301,45 @@ namespace Microsoft.DotNet.Tools.Build
private bool InvokeCompileOnRootProject() private bool InvokeCompileOnRootProject()
{ {
// todo: add methods to CompilerCommandApp to generate the arg string? // todo: add methods to CompilerCommandApp to generate the arg string?
var compileResult = Command.Create("dotnet-compile", List<string> args = new List<string>();
$"--framework {_rootProject.TargetFramework} " + args.Add("--framework");
$"--configuration {_args.ConfigValue} " + args.Add(_rootProject.TargetFramework.ToString());
$"--output \"{_args.OutputValue}\" " + args.Add("--configuration");
$"--temp-output \"{_args.IntermediateValue}\" " + args.Add(_args.ConfigValue);
(_args.NoHostValue ? "--no-host " : string.Empty) + args.Add("--output");
//nativeArgs args.Add(_args.OutputValue);
(_args.IsNativeValue ? "--native " : string.Empty) + args.Add("--temp-output");
(_args.IsCppModeValue ? "--cpp " : string.Empty) + args.Add(_args.IntermediateValue);
(!string.IsNullOrWhiteSpace(_args.ArchValue) ? $"--arch {_args.ArchValue} " : string.Empty) +
(!string.IsNullOrWhiteSpace(_args.IlcArgsValue) ? $"--ilcargs \"{_args.IlcArgsValue}\" " : string.Empty) + if (_args.NoHostValue) args.Add("--no-host");
(!string.IsNullOrWhiteSpace(_args.IlcPathValue) ? $"--ilcpath \"{_args.IlcPathValue}\" " : string.Empty) +
(!string.IsNullOrWhiteSpace(_args.IlcSdkPathValue) ? $"--ilcsdkpath \"{_args.IlcSdkPathValue}\" " : string.Empty) + //native args
$"\"{_rootProject.ProjectDirectory}\"") if (_args.IsNativeValue) args.Add("--native");
if (_args.IsCppModeValue) args.Add("--cpp");
if (!string.IsNullOrWhiteSpace(_args.ArchValue))
{
args.Add("--arch");
args.Add(_args.ArchValue);
}
if (!string.IsNullOrWhiteSpace(_args.IlcArgsValue))
{
args.Add("--ilcargs");
args.Add(_args.IlcArgsValue);
}
if (!string.IsNullOrWhiteSpace(_args.IlcPathValue))
{
args.Add("--ilcpath");
args.Add(_args.IlcPathValue);
}
if (!string.IsNullOrWhiteSpace(_args.IlcSdkPathValue))
{
args.Add("--ilcsdkpath");
args.Add(_args.IlcSdkPathValue);
}
args.Add(_rootProject.ProjectDirectory);
var compileResult = Command.Create("dotnet-compile",args.ToArray())
.ForwardStdOut() .ForwardStdOut()
.ForwardStdErr() .ForwardStdErr()
.Execute(); .Execute();

View file

@ -79,6 +79,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
return returnCode; return returnCode;
} }
sources = sources.Select(s => s.Trim('"')).ToList();
var translated = TranslateCommonOptions(commonOptions, outputName); var translated = TranslateCommonOptions(commonOptions, outputName);
var allArgs = new List<string>(translated); var allArgs = new List<string>(translated);
@ -103,7 +105,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
File.WriteAllLines(rsp, allArgs, Encoding.UTF8); File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
// Execute CSC! // Execute CSC!
var result = RunCsc($"-noconfig @\"{rsp}\"") var result = RunCsc(new string[] { $"-noconfig", "@" + $"{rsp}" })
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();
@ -214,7 +216,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
return languageVersion; return languageVersion;
} }
private static Command RunCsc(string cscArgs) private static Command RunCsc(string[] cscArgs)
{ {
// Locate CoreRun // Locate CoreRun
return Command.Create("csc", cscArgs); return Command.Create("csc", cscArgs);

View file

@ -87,7 +87,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
// Generate assembly info // Generate assembly info
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.fs"); var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.fs");
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions)); File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions));
allArgs.Add($"\"{assemblyInfo}\""); allArgs.Add($"{assemblyInfo}");
//HACK fsc raise error FS0208 if target exe doesnt have extension .exe //HACK fsc raise error FS0208 if target exe doesnt have extension .exe
bool hackFS0208 = commonOptions.EmitEntryPoint == true; bool hackFS0208 = commonOptions.EmitEntryPoint == true;
@ -100,18 +100,32 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
outputName = Path.ChangeExtension(outputName, ".exe"); outputName = Path.ChangeExtension(outputName, ".exe");
} }
allArgs.Add($"--out:\"{outputName}\""); allArgs.Add($"--out:");
allArgs.Add($"{outputName}");
} }
allArgs.AddRange(references.Select(r => $"-r:\"{r}\"")); foreach (var reference in references)
allArgs.AddRange(resources.Select(resource => $"--resource:{resource}")); {
allArgs.AddRange(sources.Select(s => $"\"{s}\"")); allArgs.Add("-r");
allArgs.Add($"{reference}");
}
foreach (var resource in resources)
{
allArgs.Add("--resource");
allArgs.Add($"{resource}");
}
foreach (var source in sources)
{
allArgs.Add($"{source}");
}
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp"); var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
File.WriteAllLines(rsp, allArgs, Encoding.UTF8); File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
// Execute FSC! // Execute FSC!
var result = RunFsc(string.Join(" ", allArgs)) var result = RunFsc(allArgs)
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();
@ -192,11 +206,16 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
return commonArgs; return commonArgs;
} }
private static Command RunFsc(string fscArgs) private static Command RunFsc(List<string> fscArgs)
{ {
var corerun = Path.Combine(AppContext.BaseDirectory, Constants.HostExecutableName); var corerun = Path.Combine(AppContext.BaseDirectory, Constants.HostExecutableName);
var fscExe = Path.Combine(AppContext.BaseDirectory, "fsc.exe"); var fscExe = Path.Combine(AppContext.BaseDirectory, "fsc.exe");
return Command.Create(corerun, $"\"{fscExe}\" {fscArgs}");
List<string> args = new List<string>();
args.Add(fscExe);
args.AddRange(fscArgs);
return Command.Create(corerun, args.ToArray());
} }
} }
} }

View file

@ -1,11 +1,6 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common;
namespace Microsoft.DotNet.Tools.Compiler.Native namespace Microsoft.DotNet.Tools.Compiler.Native
{ {
@ -13,15 +8,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
{ {
private readonly string ExecutableName = "corerun" + Constants.ExeSuffix; private readonly string ExecutableName = "corerun" + Constants.ExeSuffix;
private readonly string ILCompiler = "ilc.exe"; private readonly string ILCompiler = "ilc.exe";
private IEnumerable<string> Args;
private NativeCompileSettings config;
private static readonly Dictionary<NativeIntermediateMode, string> ModeOutputExtensionMap = new Dictionary<NativeIntermediateMode, string> private static readonly Dictionary<NativeIntermediateMode, string> ModeOutputExtensionMap = new Dictionary<NativeIntermediateMode, string>
{ {
{ NativeIntermediateMode.cpp, ".cpp" }, { NativeIntermediateMode.cpp, ".cpp" },
{ NativeIntermediateMode.ryujit, ".obj" } { NativeIntermediateMode.ryujit, ".obj" }
}; };
private string ArgStr { get; set; }
private NativeCompileSettings config;
public ILCompilerInvoker(NativeCompileSettings config) public ILCompilerInvoker(NativeCompileSettings config)
{ {
@ -39,28 +33,31 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
throw new FileNotFoundException("Unable to find ILCompiler at " + managedPath); throw new FileNotFoundException("Unable to find ILCompiler at " + managedPath);
} }
argsList.Add($"\"{managedPath}\""); argsList.Add($"{managedPath}");
// Input File // Input File
var inputFilePath = config.InputManagedAssemblyPath; var inputFilePath = config.InputManagedAssemblyPath;
argsList.Add($"\"{inputFilePath}\""); argsList.Add($"{inputFilePath}");
// System.Private.* References // System.Private.* References
var coreLibsPath = Path.Combine(config.IlcSdkPath, "sdk"); var coreLibsPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var reference in Directory.EnumerateFiles(coreLibsPath, "*.dll")) foreach (var reference in Directory.EnumerateFiles(coreLibsPath, "*.dll"))
{ {
argsList.Add($"-r \"{reference}\""); argsList.Add($"-r");
argsList.Add($"{reference}");
} }
// AppDep References // AppDep References
foreach (var reference in config.ReferencePaths) foreach (var reference in config.ReferencePaths)
{ {
argsList.Add($"-r \"{reference}\""); argsList.Add($"-r");
argsList.Add($"{reference}");
} }
// Set Output DetermineOutFile // Set Output DetermineOutFile
var outFile = DetermineOutputFile(config); var outFile = DetermineOutputFile(config);
argsList.Add($"-out \"{outFile}\""); argsList.Add($"-out");
argsList.Add($"{outFile}");
// Add Mode Flag TODO // Add Mode Flag TODO
if (config.NativeMode == NativeIntermediateMode.cpp) if (config.NativeMode == NativeIntermediateMode.cpp)
@ -74,14 +71,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
argsList.Add(config.IlcArgs); argsList.Add(config.IlcArgs);
} }
this.ArgStr = string.Join(" ", argsList); Args = argsList;
} }
public int Invoke() public int Invoke()
{ {
var executablePath = Path.Combine(config.IlcPath, ExecutableName); var executablePath = Path.Combine(config.IlcPath, ExecutableName);
var result = Command.Create(executablePath, ArgStr) var result = Command.Create(executablePath, Args)
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -1,43 +1,35 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common;
namespace Microsoft.DotNet.Tools.Compiler.Native namespace Microsoft.DotNet.Tools.Compiler.Native
{ {
public class LinuxCppCompileStep : IPlatformNativeStep public class LinuxCppCompileStep : IPlatformNativeStep
{ {
private readonly string CompilerName = "clang-3.5"; private const string CompilerName = "clang-3.5";
private readonly string InputExtension = ".cpp"; private const string InputExtension = ".cpp";
// TODO: debug/release support // TODO: debug/release support
private readonly string cLibsFlags = "-lm -ldl"; private readonly string [] _cLibsFlags = { "-lm", "-ldl"};
private readonly string cflags = "-g -lstdc++ -lrt -Wno-invalid-offsetof -pthread"; private readonly string [] _cflags = { "-g", "-lstdc++", "-lrt", "-Wno-invalid-offsetof", "-pthread"};
private readonly string[] IlcSdkLibs = new string[] public IEnumerable<string> CompilerArgs { get; set; }
{
"libbootstrappercpp.a",
"libPortableRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] appdeplibs = new string[] private readonly string[] _ilcSdkLibs =
{ {
"libSystem.Native.a" "libbootstrappercpp.a",
}; "libPortableRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] _appdeplibs =
private string CompilerArgStr { get; set; } {
private NativeCompileSettings config; "libSystem.Native.a"
};
public LinuxCppCompileStep(NativeCompileSettings config) public LinuxCppCompileStep(NativeCompileSettings config)
{ {
this.config = config;
InitializeArgs(config); InitializeArgs(config);
} }
@ -63,11 +55,11 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>(); var argsList = new List<string>();
// Flags // Flags
argsList.Add(cflags); argsList.AddRange(_cflags);
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc"); var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
argsList.Add("-I"); argsList.Add("-I");
argsList.Add($"\"{ilcSdkIncPath}\""); argsList.Add($"{ilcSdkIncPath}");
// Input File // Input File
var inCppFile = DetermineInFile(config); var inCppFile = DetermineInFile(config);
@ -80,33 +72,26 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
} }
// ILC SDK Libs // ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs) argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)));
{
var libPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add(libPath);
}
// AppDep Libs // AppDep Libs
var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04/x64"); var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04/x64");
foreach (var lib in appdeplibs) argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib)));
{
var appDeplibPath = Path.Combine(baseAppDeplibPath, lib);
argsList.Add(appDeplibPath);
}
argsList.Add(cLibsFlags); argsList.AddRange(_cLibsFlags);
// Output // Output
var libOut = DetermineOutputFile(config); var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\""); argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList); CompilerArgs = argsList;
} }
private int InvokeCompiler() private int InvokeCompiler()
{ {
var result = Command.Create(CompilerName, CompilerArgStr) var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -1,44 +1,34 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common; using System.Linq;
namespace Microsoft.DotNet.Tools.Compiler.Native namespace Microsoft.DotNet.Tools.Compiler.Native
{ {
public class LinuxRyuJitCompileStep : IPlatformNativeStep public class LinuxRyuJitCompileStep : IPlatformNativeStep
{ {
private readonly string CompilerName = "clang-3.5"; private const string CompilerName = "clang-3.5";
private readonly string InputExtension = ".obj"; private const string InputExtension = ".obj";
private const string CompilerOutputExtension = "";
private readonly string CompilerOutputExtension = ""; public List<string> CompilerArgs { get; set; }
// TODO: debug/release support // TODO: debug/release support
private readonly string cflags = "-lstdc++ -lpthread -ldl -lm -lrt"; private readonly string[] _cflags = {"-lstdc++", "-lpthread", "-ldl", "-lm", "-lrt"};
private readonly string[] _ilcSdkLibs =
{
"libbootstrapper.a",
"libRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] IlcSdkLibs = new string[] private readonly string[] _appdeplibs =
{ {
"libbootstrapper.a", "libSystem.Native.a"
"libRuntime.a", };
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] appdeplibs = new string[]
{
"libSystem.Native.a"
};
private string CompilerArgStr { get; set; }
private NativeCompileSettings config;
public LinuxRyuJitCompileStep(NativeCompileSettings config) public LinuxRyuJitCompileStep(NativeCompileSettings config)
{ {
this.config = config;
InitializeArgs(config); InitializeArgs(config);
} }
@ -64,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>(); var argsList = new List<string>();
// Flags // Flags
argsList.Add(cflags); argsList.AddRange(_cflags);
// Input File // Input File
var inLibFile = DetermineInFile(config); var inLibFile = DetermineInFile(config);
@ -77,31 +67,24 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
} }
// ILC SDK Libs // ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs) argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)));
{
var libPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add(libPath);
}
// AppDep Libs // AppDep Libs
var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04", config.Architecture.ToString()); var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04", config.Architecture.ToString());
foreach (var lib in appdeplibs) argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib)));
{
var appDepLibPath = Path.Combine(baseAppDepLibPath, lib);
argsList.Add(appDepLibPath);
}
// Output // Output
var libOut = DetermineOutputFile(config); var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\""); argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList); CompilerArgs = argsList;
} }
private int InvokeCompiler() private int InvokeCompiler()
{ {
var result = Command.Create(CompilerName, CompilerArgStr) var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -12,34 +12,32 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
{ {
public class MacCppCompileStep : IPlatformNativeStep public class MacCppCompileStep : IPlatformNativeStep
{ {
private readonly string CompilerName = "clang"; private const string CompilerName = "clang";
private readonly string InputExtension = ".cpp"; public const string InputExtension = ".cpp";
// TODO: debug/release support // TODO: debug/release support
private readonly string cflags = "-g -lstdc++ -Wno-invalid-offsetof -pthread"; private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-pthread"};
// Link to iconv APIs // Link to iconv APIs
private readonly string libFlags = "-liconv"; private const string LibFlags = "-liconv";
private readonly string[] IlcSdkLibs = new string[] private readonly string[] _ilcSdkLibs =
{ {
"libbootstrappercpp.a", "libbootstrappercpp.a",
"libPortableRuntime.a", "libPortableRuntime.a",
"libSystem.Private.CoreLib.Native.a" "libSystem.Private.CoreLib.Native.a"
}; };
private readonly string[] appdeplibs = new string[] private readonly string[] _appdeplibs =
{ {
"libSystem.Native.a" "libSystem.Native.a"
}; };
private string CompilerArgStr { get; set; } private List<string> CompilerArgs { get; set; }
private NativeCompileSettings config;
public MacCppCompileStep(NativeCompileSettings config) public MacCppCompileStep(NativeCompileSettings config)
{ {
this.config = config;
InitializeArgs(config); InitializeArgs(config);
} }
@ -65,18 +63,18 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>(); var argsList = new List<string>();
// Flags // Flags
argsList.Add(cflags); argsList.AddRange(_cflags);
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc"); var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
argsList.Add("-I"); argsList.Add("-I");
argsList.Add($"\"{ilcSdkIncPath}\""); argsList.Add($"{ilcSdkIncPath}");
// Input File // Input File
var inCppFile = DetermineInFile(config); var inCppFile = DetermineInFile(config);
argsList.Add(inCppFile); argsList.Add(inCppFile);
// Lib flags // Lib flags
argsList.Add(libFlags); argsList.Add(LibFlags);
// Pass the optional native compiler flags if specified // Pass the optional native compiler flags if specified
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
@ -85,11 +83,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
} }
// ILC SDK Libs // ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs) foreach (var libPath in _ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)))
{ {
var libPath = Path.Combine(IlcSdkLibPath, lib);
// Forward the library to linked to the linker // Forward the library to linked to the linker
argsList.Add("-Xlinker"); argsList.Add("-Xlinker");
argsList.Add(libPath); argsList.Add(libPath);
@ -97,23 +93,23 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// AppDep Libs // AppDep Libs
var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10/x64"); var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10/x64");
foreach (var lib in appdeplibs) foreach (var appDeplibPath in _appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib)))
{ {
var appDeplibPath = Path.Combine(baseAppDeplibPath, lib);
argsList.Add("-Xlinker"); argsList.Add("-Xlinker");
argsList.Add(appDeplibPath); argsList.Add(appDeplibPath);
} }
// Output // Output
var libOut = DetermineOutputFile(config); var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\""); argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList); CompilerArgs = argsList;
} }
private int InvokeCompiler() private int InvokeCompiler()
{ {
var result = Command.Create(CompilerName, CompilerArgStr) var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -1,44 +1,36 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common; using System.Linq;
namespace Microsoft.DotNet.Tools.Compiler.Native namespace Microsoft.DotNet.Tools.Compiler.Native
{ {
public class MacRyuJitCompileStep : IPlatformNativeStep public class MacRyuJitCompileStep : IPlatformNativeStep
{ {
private readonly string CompilerName = "clang"; private const string CompilerName = "clang";
private readonly string InputExtension = ".obj"; private const string InputExtension = ".obj";
private readonly string CompilerOutputExtension = ""; private const string CompilerOutputExtension = "";
private IEnumerable<string> CompilerArgs;
// TODO: debug/release support // TODO: debug/release support
private readonly string cflags = "-g -lstdc++ -Wno-invalid-offsetof -pthread -ldl -lm -liconv"; private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-pthread", "-ldl", "-lm", "-liconv" };
private readonly string[] IlcSdkLibs = new string[] private readonly string[] _ilcSdkLibs =
{ {
"libbootstrapper.a", "libbootstrapper.a",
"libRuntime.a", "libRuntime.a",
"libSystem.Private.CoreLib.Native.a" "libSystem.Private.CoreLib.Native.a"
}; };
private readonly string[] appdeplibs = new string[] private readonly string[] appdeplibs =
{ {
"libSystem.Native.a" "libSystem.Native.a"
}; };
private string CompilerArgStr { get; set; }
private NativeCompileSettings config;
public MacRyuJitCompileStep(NativeCompileSettings config) public MacRyuJitCompileStep(NativeCompileSettings config)
{ {
this.config = config;
InitializeArgs(config); InitializeArgs(config);
} }
@ -64,7 +56,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>(); var argsList = new List<string>();
// Flags // Flags
argsList.Add(cflags); argsList.AddRange(_cflags);
// Pass the optional native compiler flags if specified // Pass the optional native compiler flags if specified
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
@ -77,31 +69,24 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
argsList.Add("-Xlinker "+inLibFile); argsList.Add("-Xlinker "+inLibFile);
// ILC SDK Libs // ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk"); var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs) argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)).Select(libPath => "-Xlinker " + libPath));
{
var libPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add("-Xlinker "+libPath);
}
// AppDep Libs // AppDep Libs
var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10", config.Architecture.ToString()); var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10", config.Architecture.ToString());
foreach (var lib in appdeplibs) argsList.AddRange(appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib)).Select(appDepLibPath => "-Xlinker " + appDepLibPath));
{
var appDepLibPath = Path.Combine(baseAppDepLibPath, lib);
argsList.Add("-Xlinker "+appDepLibPath);
}
// Output // Output
var libOut = DetermineOutputFile(config); var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\""); argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList); this.CompilerArgs = argsList;
} }
private int InvokeCompiler() private int InvokeCompiler()
{ {
var result = Command.Create(CompilerName, CompilerArgStr) var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -20,13 +20,13 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
private readonly string CompilerOutputExtension = ".obj"; private readonly string CompilerOutputExtension = ".obj";
private static readonly Dictionary<BuildConfiguration, string> ConfigurationCompilerOptionsMap = new Dictionary<BuildConfiguration, string> private static readonly Dictionary<BuildConfiguration, string[]> ConfigurationCompilerOptionsMap = new Dictionary<BuildConfiguration, string[]>
{ {
{ BuildConfiguration.debug, "/ZI /nologo /W3 /WX- /sdl /Od /D CPPCODEGEN /D WIN32 /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4477 /errorReport:prompt" }, { BuildConfiguration.debug, new string[] {"/ZI", "/nologo", "/W3", "/WX-", "/sdl", "/Od", "/D", "CPPCODEGEN", "/D", "WIN32", "/D", "_CONSOLE", "/D", "_LIB", "/D", "_UNICODE", "/D", "UNICODE", "/Gm", "/EHsc", "/RTC1", "/MD", "/GS", "/fp:precise", "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", "/Gd", "/TP", "/wd4477", "/errorReport:prompt"} },
{ BuildConfiguration.release, "/Zi /nologo /W3 /WX- /sdl /O2 /Oi /GL /D CPPCODEGEN /D WIN32 /D NDEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4477 /errorReport:prompt" } { BuildConfiguration.release, new string[] {"/Zi", "/nologo", "/W3", "/WX-", "/sdl", "/O2", "/Oi", "/GL", "/D", "CPPCODEGEN", "/D", "WIN32", "/D", "NDEBUG", "/D", "_CONSOLE", "/D", "_LIB", "/D", "_UNICODE", "/D", "UNICODE", "/Gm-", "/EHsc", "/MD", "/GS", "/Gy", "/fp:precise", "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", "/Gd", "/TP", "/wd4477", "/errorReport:prompt"} }
}; };
private string CompilerArgStr { get; set; } private IEnumerable<string> CompilerArgs { get; set; }
private NativeCompileSettings config; private NativeCompileSettings config;
@ -70,10 +70,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Add Includes // Add Includes
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc"); var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
argsList.Add("/I"); argsList.Add("/I");
argsList.Add($"\"{ilcSdkIncPath}\""); argsList.Add($"{ilcSdkIncPath}");
// Configuration Based Compiler Options // Configuration Based Compiler Options
argsList.Add(ConfigurationCompilerOptionsMap[config.BuildType]); argsList.AddRange(ConfigurationCompilerOptionsMap[config.BuildType]);
// Pass the optional native compiler flags if specified // Pass the optional native compiler flags if specified
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags)) if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
@ -83,13 +83,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Output // Output
var objOut = DetermineOutputFile(config); var objOut = DetermineOutputFile(config);
argsList.Add($"/Fo\"{objOut}\""); argsList.Add($"/Fo");
argsList.Add($"{objOut}");
// Input File // Input File
var inCppFile = DetermineInFile(config); var inCppFile = DetermineInFile(config);
argsList.Add($"\"{inCppFile}\""); argsList.Add($"{inCppFile}");
this.CompilerArgStr = string.Join(" ", argsList); this.CompilerArgs = argsList;
} }
private int InvokeCompiler() private int InvokeCompiler()
@ -97,7 +98,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS"); var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
var compilerPath = Path.Combine(vcInstallDir, VSBin, CompilerName); var compilerPath = Path.Combine(vcInstallDir, VSBin, CompilerName);
var result = Command.Create(compilerPath, CompilerArgStr) var result = Command.Create(compilerPath, CompilerArgs.ToArray())
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -54,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
{ BuildConfiguration.release , new string[] { "msvcrt.lib" } } { BuildConfiguration.release , new string[] { "msvcrt.lib" } }
}; };
private string ArgStr { get; set; } private IEnumerable<string> Args { get; set; }
private NativeCompileSettings config; private NativeCompileSettings config;
public WindowsLinkStep(NativeCompileSettings config) public WindowsLinkStep(NativeCompileSettings config)
@ -95,10 +95,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
//Output //Output
var outFile = DetermineOutputFile(config); var outFile = DetermineOutputFile(config);
argsList.Add($"/out:\"{outFile}\""); argsList.Add($"/out");
argsList.Add($"{outFile}");
// Constant Libs // Constant Libs
argsList.Add(string.Join(" ", ConstantLinkLibs)); foreach (var lib in ConstantLinkLibs)
{
argsList.Add(lib);
}
// ILC SDK Libs // ILC SDK Libs
var SDKLibs = IlcSdkLibMap[config.NativeMode]; var SDKLibs = IlcSdkLibMap[config.NativeMode];
@ -106,19 +110,19 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
foreach (var lib in SDKLibs) foreach (var lib in SDKLibs)
{ {
var sdkLibPath = Path.Combine(IlcSdkLibPath, lib); var sdkLibPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add($"\"{sdkLibPath}\""); argsList.Add($"{sdkLibPath}");
} }
// Configuration Based Libs // Configuration Based Libs
var configLibs = ConfigurationLinkLibMap[config.BuildType]; var configLibs = ConfigurationLinkLibMap[config.BuildType];
foreach (var lib in configLibs) foreach (var lib in configLibs)
{ {
argsList.Add($"\"{lib}\""); argsList.Add($"{lib}");
} }
// Link Libs // Link Libs
foreach(var path in config.LinkLibPaths){ foreach(var path in config.LinkLibPaths){
argsList.Add($"\"{path}\""); argsList.Add($"{path}");
} }
//arch //arch
@ -126,9 +130,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
//Input Obj file //Input Obj file
var inputFile = DetermineInputFile(config); var inputFile = DetermineInputFile(config);
argsList.Add($"\"{inputFile}\""); argsList.Add($"{inputFile}");
this.ArgStr = string.Join(" ", argsList); this.Args = argsList;
} }
private int InvokeLinker() private int InvokeLinker()
@ -136,7 +140,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS"); var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName); var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName);
var result = Command.Create(linkerPath, ArgStr) var result = Command.Create(linkerPath, Args.ToArray())
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -150,7 +150,7 @@ namespace Microsoft.DotNet.Tools.Compiler
// Need CoreRT Framework published to nuget // Need CoreRT Framework published to nuget
// Do Native Compilation // Do Native Compilation
var result = Command.Create("dotnet-compile-native", $"--rsp \"{rsp}\"") var result = Command.Create("dotnet-compile-native", new string[] { "--rsp", $"{rsp}" })
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();
@ -238,10 +238,10 @@ namespace Microsoft.DotNet.Tools.Compiler
references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath)); references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath));
} }
compilerArgs.AddRange(dependency.SourceReferences); compilerArgs.AddRange(dependency.SourceReferences.Select(s => $"\"{s}\""));
} }
compilerArgs.AddRange(references.Select(r => $"--reference:{r}")); compilerArgs.AddRange(references.Select(r => $"--reference:\"{r}\""));
if (compilationOptions.PreserveCompilationContext == true) if (compilationOptions.PreserveCompilationContext == true)
{ {
@ -298,7 +298,7 @@ namespace Microsoft.DotNet.Tools.Compiler
}; };
RunScripts(context, ScriptNames.PreCompile, contextVariables); RunScripts(context, ScriptNames.PreCompile, contextVariables);
var result = Command.Create($"dotnet-compile-{compilerName}", $"@\"{rsp}\"") var result = Command.Create($"dotnet-compile-{compilerName}", new string[] {"@" + $"{rsp}" })
.OnErrorLine(line => .OnErrorLine(line =>
{ {
var diagnostic = ParseDiagnostic(context.ProjectDirectory, line); var diagnostic = ParseDiagnostic(context.ProjectDirectory, line);
@ -423,7 +423,14 @@ namespace Microsoft.DotNet.Tools.Compiler
{ {
var result = var result =
Command.Create("dotnet-resgen", Command.Create("dotnet-resgen",
$"\"{resgenFile.InputFile}\" -o \"{resgenFile.OutputFile}\" -v \"{project.Version.Version}\"") new string[]
{
$"{resgenFile.InputFile}",
"-o",
$"{resgenFile.OutputFile}",
"-v",
$"{project.Version.Version}"
})
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -5,6 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
using System.Collections.Generic;
namespace Microsoft.DotNet.Tools.Pack namespace Microsoft.DotNet.Tools.Pack
{ {
@ -39,22 +40,25 @@ namespace Microsoft.DotNet.Tools.Pack
if (_project.Files.SourceFiles.Any()) if (_project.Files.SourceFiles.Any())
{ {
var argsBuilder = new StringBuilder(); var argsBuilder = new List<string>();
argsBuilder.Append($"--configuration {_configuration}"); argsBuilder.Add("--configuration");
argsBuilder.Add($"{_configuration}");
if (_artifactPathsCalculator.PackageOutputPathSet) if (_artifactPathsCalculator.PackageOutputPathSet)
{ {
argsBuilder.Append($" --output \"{_artifactPathsCalculator.PackageOutputPathParameter}\""); argsBuilder.Add("--output");
argsBuilder.Add($"{_artifactPathsCalculator.PackageOutputPathParameter}");
} }
if (!string.IsNullOrEmpty(_intermediateOutputPath)) if (!string.IsNullOrEmpty(_intermediateOutputPath))
{ {
argsBuilder.Append($" --temp-output \"{_intermediateOutputPath}\""); argsBuilder.Add("--temp-output");
argsBuilder.Add($"{_intermediateOutputPath}");
} }
argsBuilder.Append($" \"{_project.ProjectFilePath}\""); argsBuilder.Add($"{_project.ProjectFilePath}");
var result = Command.Create("dotnet-build", argsBuilder.ToString()) var result = Command.Create("dotnet-build", argsBuilder)
.ForwardStdOut() .ForwardStdOut()
.ForwardStdErr() .ForwardStdErr()
.Execute(); .Execute();

View file

@ -102,12 +102,17 @@ namespace Microsoft.DotNet.Tools.Publish
} }
// Compile the project (and transitively, all it's dependencies) // Compile the project (and transitively, all it's dependencies)
var result = Command.Create("dotnet-build", var result = Command.Create("dotnet-build",
$"--framework \"{context.TargetFramework.DotNetFrameworkName}\" " + new string[] {
$"--output \"{outputPathCalculator.BaseCompilationOutputPath}\" " + "--framework",
$"--configuration \"{configuration}\" " + $"{context.TargetFramework.DotNetFrameworkName}",
"--no-host " + "--output",
$"\"{context.ProjectFile.ProjectDirectory}\"") $"{outputPathCalculator.BaseCompilationOutputPath}",
"--configuration",
$"{configuration}",
"--no-host",
$"{context.ProjectFile.ProjectDirectory}"
})
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.Execute(); .Execute();

View file

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.IO; using System.IO;
using System.Text;
using Microsoft.Dnx.Runtime.Common.CommandLine; using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
@ -60,10 +59,21 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
Reporter.Output.WriteLine($"Compiling {projectContext.RootProject.Identity.Name.Yellow()} for {projectContext.TargetFramework.DotNetFrameworkName.Yellow()} to use with the {"C# REPL".Yellow()} environment."); 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) // --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.Create($"dotnet-build", $"--output \"{tempOutputDir}\" --temp-output \"{tempOutputDir}\" --framework \"{projectContext.TargetFramework}\" --configuration \"{configuration}\" \"{projectContext.ProjectDirectory}\"") return Command.Create($"dotnet-build", new []
.ForwardStdOut(onlyIfVerbose: true) {
.ForwardStdErr() $"--output",
.Execute(); $"{tempOutputDir}",
$"--temp-output",
$"{tempOutputDir}",
$"--framework",
$"{projectContext.TargetFramework}",
$"--configuration",
$"{configuration}",
$"{projectContext.ProjectDirectory}"
})
.ForwardStdOut(onlyIfVerbose: true)
.ForwardStdErr()
.Execute();
} }
private static IEnumerable<string> GetRuntimeDependencies(ProjectContext projectContext, string buildConfiguration) private static IEnumerable<string> GetRuntimeDependencies(ProjectContext projectContext, string buildConfiguration)
@ -148,7 +158,7 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
} }
string responseFile = CreateResponseFile(projectContext, buildConfiguration, tempOutputDir); string responseFile = CreateResponseFile(projectContext, buildConfiguration, tempOutputDir);
csiArgs.Add($"@\"{responseFile}\""); csiArgs.Add($"@{responseFile}");
} }
if (string.IsNullOrEmpty(script) && !remainingArguments.Any()) if (string.IsNullOrEmpty(script) && !remainingArguments.Any())

View file

@ -90,7 +90,18 @@ namespace Microsoft.DotNet.Tools.Run
var tempDir = Path.Combine(_context.ProjectDirectory, "bin", ".dotnetrun", Guid.NewGuid().ToString("N")); var tempDir = Path.Combine(_context.ProjectDirectory, "bin", ".dotnetrun", Guid.NewGuid().ToString("N"));
// Compile to that directory // Compile to that directory
var result = Command.Create($"dotnet-build", $"--output \"{tempDir}\" --temp-output \"{tempDir}\" --framework \"{_context.TargetFramework}\" --configuration \"{Configuration}\" {_context.ProjectFile.ProjectDirectory}") var result = Command.Create($"dotnet-build", new []
{
$"--output",
$"{tempDir}",
$"--temp-output",
$"{tempDir}",
$"--framework",
$"{_context.TargetFramework}",
$"--configuration",
$"{Configuration}",
$"{_context.ProjectFile.ProjectDirectory}"
})
.ForwardStdOut(onlyIfVerbose: true) .ForwardStdOut(onlyIfVerbose: true)
.ForwardStdErr() .ForwardStdErr()
.Execute(); .Execute();
@ -134,7 +145,7 @@ namespace Microsoft.DotNet.Tools.Run
} }
} }
result = Command.Create(outputName, string.Join(" ", _args)) result = Command.Create(outputName, _args)
.ForwardStdOut() .ForwardStdOut()
.ForwardStdErr() .ForwardStdErr()
.EnvironmentVariable("DOTNET_HOME", runtime) .EnvironmentVariable("DOTNET_HOME", runtime)
@ -151,7 +162,7 @@ namespace Microsoft.DotNet.Tools.Run
private static int RunInteractive(string scriptName) private static int RunInteractive(string scriptName)
{ {
var command = Command.Create($"dotnet-repl-csi", scriptName) var command = Command.Create($"dotnet-repl-csi", new [] {scriptName})
.ForwardStdOut() .ForwardStdOut()
.ForwardStdErr(); .ForwardStdErr();
var result = command.Execute(); var result = command.Execute();

View file

@ -185,7 +185,7 @@ namespace Microsoft.DotNet.Tools.Restore
Console.WriteLine($"Restoring Tool '{tooldep.Name}' for '{projectPath}' in '{tempPath}'"); Console.WriteLine($"Restoring Tool '{tooldep.Name}' for '{projectPath}' in '{tempPath}'");
File.WriteAllText(projectPath, GenerateProjectJsonContents(new[] {"dnxcore50"}, tooldep)); File.WriteAllText(projectPath, GenerateProjectJsonContents(new[] {"dnxcore50"}, tooldep));
NuGet3.Restore(new [] { $"\"{projectPath}\"", "--runtime", $"{DefaultRid}"}.Concat(args), quiet); NuGet3.Restore(new [] { $"{projectPath}", "--runtime", $"{DefaultRid}"}.Concat(args), quiet);
} }
private static string GenerateProjectJsonContents(IEnumerable<string> frameworks, LibraryRange tooldep) private static string GenerateProjectJsonContents(IEnumerable<string> frameworks, LibraryRange tooldep)

View file

@ -16,8 +16,8 @@
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23704", "Microsoft.NETCore.TestHost": "1.0.0-rc2-23704",
"NETStandard.Library": "1.0.0-rc2-23704", "NETStandard.Library": "1.0.0-rc2-23704",
"System.Linq.Expressions": "4.0.11-rc2-23704", "System.Linq.Expressions": "4.0.11-rc2-23704",
"Microsoft.DotNet.Cli.Utils": "1.0.0-*", "Microsoft.DotNet.Cli.Utils": {"target":"project"},
"Microsoft.DotNet.Compiler.Common": "1.0.0-*", "Microsoft.DotNet.Compiler.Common": {"target":"project"},
"Microsoft.Dnx.Runtime.CommandParsing.Sources": { "Microsoft.Dnx.Runtime.CommandParsing.Sources": {
"version": "1.0.0-*", "version": "1.0.0-*",
"type": "build" "type": "build"