Add Microsoft.DotNet.Tools.Interactive
This commit is contained in:
parent
54847cf032
commit
e2cdf17e2e
14 changed files with 278 additions and 37 deletions
|
@ -34,6 +34,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dnxhost", "dnxhost", "{0773
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Compiler.Csc", "src\Microsoft.DotNet.Tools.Compiler.Csc\Microsoft.DotNet.Tools.Compiler.Csc.xproj", "{B559378C-FC03-45FA-893C-71784F28E0A2}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Interactive", "src\Microsoft.DotNet.Tools.Interactive\Microsoft.DotNet.Tools.Interactive.xproj", "{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Interactive.Csi", "src\Microsoft.DotNet.Tools.Interactive.Csi\Microsoft.DotNet.Tools.Interactive.Csi.xproj", "{717A4ED9-8897-492F-BD0C-230FCAEA9237}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Tools.Resgen", "src\Microsoft.DotNet.Tools.Resgen\Microsoft.DotNet.Tools.Resgen.xproj", "{585FC6F6-48E0-4EA5-8015-0264614E97C0}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.ProjectModel", "src\Microsoft.DotNet.ProjectModel\Microsoft.DotNet.ProjectModel.xproj", "{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6}"
|
||||
|
@ -174,6 +178,22 @@ Global
|
|||
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|x64.ActiveCfg = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.MinSizeRel|x64.Build.0 = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F}.Debug|x64.Build.0 = Debug|x64
|
||||
|
@ -242,6 +262,22 @@ Global
|
|||
{A16958E1-24C7-4F1E-B317-204AD91625DD}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{A16958E1-24C7-4F1E-B317-204AD91625DD}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{A16958E1-24C7-4F1E-B317-204AD91625DD}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.MinSizeRel|x64.Build.0 = Debug|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.Release|x64.Build.0 = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -255,11 +291,13 @@ Global
|
|||
{B559378C-FC03-45FA-893C-71784F28E0A2} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{585FC6F6-48E0-4EA5-8015-0264614E97C0} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{303677D5-7312-4C3F-BAEE-BEB1A9BD9FE6} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{B317356C-99DE-499E-8B4D-D6BEC5DA57D5} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{C0CA389D-A35E-4082-BC05-598C9D6301BC} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{8DF8403E-0DDC-4E6C-9930-4C1006E96B2F} = {C0CA389D-A35E-4082-BC05-598C9D6301BC}
|
||||
{3673DD4B-F7D3-40A1-A756-F8354A5B74CD} = {C0CA389D-A35E-4082-BC05-598C9D6301BC}
|
||||
{5D67FC6A-6392-4807-97BC-D13CA0FF5E6D} = {C0CA389D-A35E-4082-BC05-598C9D6301BC}
|
||||
{1C16108C-C786-482D-BB0A-36BDAFE109ED} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{A16958E1-24C7-4F1E-B317-204AD91625DD} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
{717A4ED9-8897-492F-BD0C-230FCAEA9237} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -62,6 +62,14 @@ echo Building stage1 dotnet-compile-csc.exe ...
|
|||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-interactive.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Interactive"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-interactive-csi.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Interactive.Csi"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-publish.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
|
||||
if errorlevel 1 goto fail
|
||||
|
@ -99,6 +107,14 @@ echo Building stage2 dotnet-compile-csc.exe ...
|
|||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-interactive.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Interactive"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-interactive-csi.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Interactive.Csi"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-publish.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
|
||||
if errorlevel 1 goto fail
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
public static Command Create(string executable, IEnumerable<string> args)
|
||||
{
|
||||
return Create(executable, args.Any() ? string.Join(" ", args) : string.Empty);
|
||||
return Create(executable, string.Join(" ", args));
|
||||
}
|
||||
|
||||
public static Command Create(string executable, string args)
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
"dependencies": {
|
||||
"System.CommandLine": "0.1.0-*",
|
||||
"System.Linq": "4.0.1-beta-23502",
|
||||
"System.Runtime": "4.0.21-beta-23502",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
"System.Runtime": "4.0.21-beta-23504",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*"
|
||||
},
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace Microsoft.Extensions.ProjectModel
|
|||
{
|
||||
try
|
||||
{
|
||||
var buildVersion = Environment.GetEnvironmentVariable("DOETNET_BUILD_VERSION");
|
||||
var buildVersion = Environment.GetEnvironmentVariable("DOTNET_BUILD_VERSION");
|
||||
project.Version = SpecifySnapshot(version, buildVersion);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -46,33 +46,23 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
|
||||
var buildProjectReferences = !noProjectDependencies.HasValue();
|
||||
var isNative = native.HasValue();
|
||||
var configValue = configuration.Value() ?? Constants.DefaultConfiguration;
|
||||
var outputValue = output.Value();
|
||||
|
||||
// Load project contexts for each framework and compile them
|
||||
bool success = true;
|
||||
if (framework.HasValue())
|
||||
var contexts = framework.HasValue() ?
|
||||
framework.Values.Select(f => ProjectContext.Create(path, NuGetFramework.Parse(f))) :
|
||||
ProjectContext.CreateContextForEachFramework(path);
|
||||
foreach (var context in contexts)
|
||||
{
|
||||
foreach (var context in framework.Values.Select(f => ProjectContext.Create(path, NuGetFramework.Parse(f))))
|
||||
success &= Compile(context, configValue, outputValue, intermediateOutput.Value(), buildProjectReferences);
|
||||
if (isNative)
|
||||
{
|
||||
success &= Compile(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), intermediateOutput.Value(), buildProjectReferences);
|
||||
|
||||
if (isNative)
|
||||
{
|
||||
success &= CompileNative(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), buildProjectReferences);
|
||||
}
|
||||
success &= CompileNative(context, configValue, outputValue, buildProjectReferences);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var context in ProjectContext.CreateContextForEachFramework(path))
|
||||
{
|
||||
success &= Compile(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), intermediateOutput.Value(), buildProjectReferences);
|
||||
|
||||
if (isNative)
|
||||
{
|
||||
success &= CompileNative(context, configuration.Value() ?? Constants.DefaultConfiguration, output.Value(), buildProjectReferences);
|
||||
}
|
||||
}
|
||||
}
|
||||
return success ? 0 : 1;
|
||||
});
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"System.Linq": "4.0.1-beta-23504",
|
||||
"System.Diagnostics.Process": "4.1.0-beta-23504",
|
||||
"System.IO.FileSystem": "4.0.1-beta-23504",
|
||||
"System.AppContext": "4.0.1-beta-23504",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||
|
@ -22,8 +23,7 @@
|
|||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Net.Compilers.netcore": "1.1.0-*"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>717a4ed9-8897-492f-bd0c-230fcaea9237</ProjectGuid>
|
||||
<RootNamespace>Microsoft.DotNet.Tools.Interactive.Csi</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
38
src/Microsoft.DotNet.Tools.Interactive.Csi/Program.cs
Normal file
38
src/Microsoft.DotNet.Tools.Interactive.Csi/Program.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Interactive.Csi
|
||||
{
|
||||
public sealed class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
var app = new CommandLineApplication();
|
||||
app.Name = "dotnet interactive csi";
|
||||
app.FullName = "CSharp Interactive";
|
||||
app.Description = "CSharp Interactive for the .NET platform";
|
||||
app.HelpOption("-h|--help");
|
||||
var script = app.Argument("<SCRIPT>", "The .csx file to run. Defaults to interactive mode.");
|
||||
|
||||
app.OnExecute(() => Run(script.Value));
|
||||
return app.Execute(args);
|
||||
}
|
||||
|
||||
private static int Run(string scriptOpt)
|
||||
{
|
||||
var corerun = Path.Combine(AppContext.BaseDirectory, Constants.HostExecutableName);
|
||||
var csiExe = Path.Combine(AppContext.BaseDirectory, "csi.exe");
|
||||
var csiArgs = string.IsNullOrEmpty(scriptOpt) ? "-i" : scriptOpt;
|
||||
var command = File.Exists(corerun) && File.Exists(csiExe) ?
|
||||
Command.Create(corerun, $@"""{csiExe}"" {csiArgs}") :
|
||||
Command.Create(csiExe, csiArgs);
|
||||
command = command.ForwardStdOut().ForwardStdErr();
|
||||
var result = command.Execute();
|
||||
return result.ExitCode;
|
||||
}
|
||||
}
|
||||
}
|
29
src/Microsoft.DotNet.Tools.Interactive.Csi/project.json
Normal file
29
src/Microsoft.DotNet.Tools.Interactive.Csi/project.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "dotnet-interactive-csi",
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
"System.Diagnostics.Process": "4.1.0-beta-23504",
|
||||
"System.IO.FileSystem": "4.0.1-beta-23504",
|
||||
"System.AppContext": "4.0.1-beta-23504",
|
||||
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>b317356c-99de-499e-8b4d-d6bec5da57d5</ProjectGuid>
|
||||
<RootNamespace>Microsoft.DotNet.Tools.Interactive</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
43
src/Microsoft.DotNet.Tools.Interactive/Program.cs
Normal file
43
src/Microsoft.DotNet.Tools.Interactive/Program.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using Microsoft.Dnx.Runtime.Common.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Interactive
|
||||
{
|
||||
public sealed class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
var app = new CommandLineApplication();
|
||||
app.Name = "dotnet interactive";
|
||||
app.FullName = ".NET interactive";
|
||||
app.Description = "Interactive for the .NET platform";
|
||||
app.HelpOption("-h|--help");
|
||||
var language = app.Argument("<LANGUAGE>", "The interactive programming language, defaults to csharp");
|
||||
|
||||
app.OnExecute(() => Run(language.Value));
|
||||
return app.Execute(args);
|
||||
}
|
||||
|
||||
private static int Run(string languageOpt)
|
||||
{
|
||||
string interactiveName;
|
||||
if ((languageOpt == null) || (languageOpt == "csharp"))
|
||||
{
|
||||
interactiveName = "csi";
|
||||
}
|
||||
else
|
||||
{
|
||||
Reporter.Error.WriteLine($"Unrecognized language: {languageOpt}".Red());
|
||||
return -1;
|
||||
}
|
||||
var command = Command.Create($"dotnet-interactive-{interactiveName}", string.Empty)
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr();
|
||||
var result = command.Execute();
|
||||
return result.ExitCode;
|
||||
}
|
||||
}
|
||||
}
|
29
src/Microsoft.DotNet.Tools.Interactive/project.json
Normal file
29
src/Microsoft.DotNet.Tools.Interactive/project.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "dotnet-interactive",
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
"System.Diagnostics.Process": "4.1.0-beta-23504",
|
||||
"System.IO.FileSystem": "4.0.1-beta-23504",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
|
@ -25,27 +25,36 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
var framework = app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.MultipleValue);
|
||||
var configuration = app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
|
||||
var preserveTemporaryOutput = app.Option("-t|--preserve-temporary", "Keep the output's temporary directory around", CommandOptionType.NoValue);
|
||||
var project = app.Option("-p|--project <PROJECT_PATH>", "The path to the project to run (defaults to the current directory)", CommandOptionType.SingleValue);
|
||||
var project = app.Argument("<PROJECT>", "The project to run, defaults to the current directory. Can be a path to a project.json or a project directory");
|
||||
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
// Locate the project and get the name and full path
|
||||
var path = Directory.GetCurrentDirectory();
|
||||
if(project.HasValue())
|
||||
var path = project.Value;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = project.Value();
|
||||
}
|
||||
|
||||
var contexts = ProjectContext.CreateContextForEachFramework(path);
|
||||
if (!framework.HasValue())
|
||||
{
|
||||
return Run(contexts.First(), configuration.Value() ?? Constants.DefaultConfiguration, app.RemainingArguments, preserveTemporaryOutput.HasValue());
|
||||
if (File.Exists(path) && (Path.GetExtension(path) == ".csx"))
|
||||
{
|
||||
return RunInteractive(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var context = contexts.FirstOrDefault(c => c.TargetFramework.Equals(NuGetFramework.Parse(framework.Value())));
|
||||
return Run(context, configuration.Value() ?? Constants.DefaultConfiguration, app.RemainingArguments, preserveTemporaryOutput.HasValue());
|
||||
path = Directory.GetCurrentDirectory();
|
||||
}
|
||||
|
||||
var contexts = ProjectContext.CreateContextForEachFramework(path);
|
||||
ProjectContext context;
|
||||
if (!framework.HasValue())
|
||||
{
|
||||
context = contexts.First();
|
||||
}
|
||||
else
|
||||
{
|
||||
var fx = NuGetFramework.Parse(framework.Value());
|
||||
context = contexts.FirstOrDefault(c => c.TargetFramework.Equals(fx));
|
||||
}
|
||||
return Run(context, configuration.Value() ?? Constants.DefaultConfiguration, app.RemainingArguments, preserveTemporaryOutput.HasValue());
|
||||
});
|
||||
|
||||
try
|
||||
|
@ -113,5 +122,14 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
|
||||
return result.ExitCode;
|
||||
}
|
||||
|
||||
private static int RunInteractive(string scriptName)
|
||||
{
|
||||
var command = Command.Create($"dotnet-interactive-csi", scriptName)
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr();
|
||||
var result = command.Execute();
|
||||
return result.ExitCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue