From 0781d7649ad70492bad1073fda2035ab42e22f6b Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Thu, 15 Oct 2015 16:12:56 -0700 Subject: [PATCH] Use csc on coreclr --- NuGet.Config | 1 + src/Microsoft.DotNet.Tools.Compiler/Program.cs | 13 ++++++++++++- src/Microsoft.DotNet.Tools.Compiler/project.json | 4 +++- src/Microsoft.Extensions.ProjectModel/Project.cs | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 892f7c825..347ae77b5 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -5,6 +5,7 @@ + diff --git a/src/Microsoft.DotNet.Tools.Compiler/Program.cs b/src/Microsoft.DotNet.Tools.Compiler/Program.cs index e89c4617f..cf8c72eaa 100644 --- a/src/Microsoft.DotNet.Tools.Compiler/Program.cs +++ b/src/Microsoft.DotNet.Tools.Compiler/Program.cs @@ -141,7 +141,7 @@ namespace Microsoft.DotNet.Tools.Compiler File.WriteAllLines(rsp, cscArgs); // Execute CSC! - var result = Command.Create("csc", $"-noconfig @\"{rsp}\"") + var result = RunCsc($"-noconfig @\"{rsp}\"") .ForwardStdErr() .ForwardStdOut() .RunAsync() @@ -149,6 +149,17 @@ namespace Microsoft.DotNet.Tools.Compiler return result.ExitCode == 0; } + private static Command RunCsc(string cscArgs) + { + // Hack -- if we find csc + corerun in the app directory we should + // use that, otherwise just try to find csc on the PATH + var corerun = Path.Combine(AppContext.BaseDirectory, "CoreRun.exe"); + var csc_exe = Path.Combine(AppContext.BaseDirectory, "csc.exe"); + return File.Exists(corerun) && File.Exists(csc_exe) + ? Command.Create(corerun, $@"""{csc_exe}"" {cscArgs}") + : Command.Create("csc.exe", cscArgs); + } + private static void ApplyCompilationOptions(CompilerOptions compilationOptions, List cscArgs) { var targetType = compilationOptions.EmitEntryPoint.GetValueOrDefault() ? "exe" : "library"; diff --git a/src/Microsoft.DotNet.Tools.Compiler/project.json b/src/Microsoft.DotNet.Tools.Compiler/project.json index 29cdb86e7..05abb8573 100644 --- a/src/Microsoft.DotNet.Tools.Compiler/project.json +++ b/src/Microsoft.DotNet.Tools.Compiler/project.json @@ -8,6 +8,7 @@ }, "dependencies": { "Microsoft.NETCore.ConsoleHost": "1.0.0-*", + "Microsoft.NETCore.TestHost": "1.0.0-*", "Microsoft.NETCore.Runtime": "1.0.1-*", "System.Console": "4.0.0-*", @@ -23,7 +24,8 @@ "Microsoft.Extensions.CommandLineUtils.Sources": { "type": "build", "version": "1.0.0-*" - } + }, + "Microsoft.Net.Compilers.netcore": "1.1.0-*", }, "frameworks": { "dnxcore50": { } diff --git a/src/Microsoft.Extensions.ProjectModel/Project.cs b/src/Microsoft.Extensions.ProjectModel/Project.cs index f093077de..71922d31c 100644 --- a/src/Microsoft.Extensions.ProjectModel/Project.cs +++ b/src/Microsoft.Extensions.ProjectModel/Project.cs @@ -123,7 +123,7 @@ namespace Microsoft.Extensions.ProjectModel } // Assume the directory name is the project name if none was specified - var projectName = PathUtility.GetDirectoryName(path); + var projectName = PathUtility.GetDirectoryName(Path.GetFullPath(path)); projectPath = Path.GetFullPath(projectPath); if (!File.Exists(projectPath))