Use csc on coreclr

This commit is contained in:
Andy Gocke 2015-10-15 16:12:56 -07:00 committed by David Fowler
parent 64f539e100
commit 0781d7649a
4 changed files with 17 additions and 3 deletions

View file

@ -5,6 +5,7 @@
<clear /> <clear />
<add key="AspNetCIDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" /> <add key="AspNetCIDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" /> <add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="roslyn-nightly" value="https://www.myget.org/F/roslyn-nightly/api/v3/index.json" />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources> </packageSources>
<activePackageSource> <activePackageSource>

View file

@ -141,7 +141,7 @@ namespace Microsoft.DotNet.Tools.Compiler
File.WriteAllLines(rsp, cscArgs); File.WriteAllLines(rsp, cscArgs);
// Execute CSC! // Execute CSC!
var result = Command.Create("csc", $"-noconfig @\"{rsp}\"") var result = RunCsc($"-noconfig @\"{rsp}\"")
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.RunAsync() .RunAsync()
@ -149,6 +149,17 @@ namespace Microsoft.DotNet.Tools.Compiler
return result.ExitCode == 0; 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<string> cscArgs) private static void ApplyCompilationOptions(CompilerOptions compilationOptions, List<string> cscArgs)
{ {
var targetType = compilationOptions.EmitEntryPoint.GetValueOrDefault() ? "exe" : "library"; var targetType = compilationOptions.EmitEntryPoint.GetValueOrDefault() ? "exe" : "library";

View file

@ -8,6 +8,7 @@
}, },
"dependencies": { "dependencies": {
"Microsoft.NETCore.ConsoleHost": "1.0.0-*", "Microsoft.NETCore.ConsoleHost": "1.0.0-*",
"Microsoft.NETCore.TestHost": "1.0.0-*",
"Microsoft.NETCore.Runtime": "1.0.1-*", "Microsoft.NETCore.Runtime": "1.0.1-*",
"System.Console": "4.0.0-*", "System.Console": "4.0.0-*",
@ -23,7 +24,8 @@
"Microsoft.Extensions.CommandLineUtils.Sources": { "Microsoft.Extensions.CommandLineUtils.Sources": {
"type": "build", "type": "build",
"version": "1.0.0-*" "version": "1.0.0-*"
} },
"Microsoft.Net.Compilers.netcore": "1.1.0-*",
}, },
"frameworks": { "frameworks": {
"dnxcore50": { } "dnxcore50": { }

View file

@ -123,7 +123,7 @@ namespace Microsoft.Extensions.ProjectModel
} }
// Assume the directory name is the project name if none was specified // 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); projectPath = Path.GetFullPath(projectPath);
if (!File.Exists(projectPath)) if (!File.Exists(projectPath))