From b95f9c395c0decc17fad39e671bc7f0a6e888c63 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 21 May 2018 14:23:29 +0200 Subject: [PATCH] Allows .NET Core apps to be optionally run using the Mono runtime Fixes #6043 --- .../dotnet-run/LocalizableStrings.resx | 6 ++++++ src/dotnet/commands/dotnet-run/RunCommand.cs | 11 ++++++++++ .../commands/dotnet-run/RunCommandParser.cs | 20 ++++++++++++++++++- .../dotnet-run/xlf/LocalizableStrings.cs.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.de.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.es.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.fr.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.it.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.ja.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.ko.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.pl.xlf | 8 ++++++++ .../xlf/LocalizableStrings.pt-BR.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.ru.xlf | 8 ++++++++ .../dotnet-run/xlf/LocalizableStrings.tr.xlf | 8 ++++++++ .../xlf/LocalizableStrings.zh-Hans.xlf | 8 ++++++++ .../xlf/LocalizableStrings.zh-Hant.xlf | 8 ++++++++ 16 files changed, 140 insertions(+), 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-run/LocalizableStrings.resx b/src/dotnet/commands/dotnet-run/LocalizableStrings.resx index e04e7c0045..964f633298 100644 --- a/src/dotnet/commands/dotnet-run/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-run/LocalizableStrings.resx @@ -144,6 +144,12 @@ The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + + + RUNTIME + The build failed. Please fix the build errors and run again. diff --git a/src/dotnet/commands/dotnet-run/RunCommand.cs b/src/dotnet/commands/dotnet-run/RunCommand.cs index 307a2fff73..ed334007f8 100644 --- a/src/dotnet/commands/dotnet-run/RunCommand.cs +++ b/src/dotnet/commands/dotnet-run/RunCommand.cs @@ -31,6 +31,8 @@ public partial class RunCommand public bool NoLaunchProfile { get; private set; } private bool UseLaunchProfile => !NoLaunchProfile; + public string ExecutingRuntime { get; private set; } + public int Start() { Initialize(); @@ -69,6 +71,7 @@ public RunCommand(string configuration, string launchProfile, bool noLaunchProfile, bool noRestore, + string executingRuntime, IEnumerable restoreArgs, IReadOnlyCollection args) { @@ -81,6 +84,7 @@ public RunCommand(string configuration, Args = args; RestoreArgs = restoreArgs; NoRestore = noRestore; + ExecutingRuntime = executingRuntime; } public RunCommand MakeNewWithReplaced(string configuration = null, @@ -90,6 +94,7 @@ public RunCommand MakeNewWithReplaced(string configuration = null, string launchProfile = null, bool? noLaunchProfile = null, bool? noRestore = null, + string executingRuntime = null, IEnumerable restoreArgs = null, IReadOnlyCollection args = null) { @@ -101,6 +106,7 @@ public RunCommand MakeNewWithReplaced(string configuration = null, launchProfile ?? this.LaunchProfile, noLaunchProfile ?? this.NoLaunchProfile, noRestore ?? this.NoRestore, + executingRuntime ?? this.ExecutingRuntime, restoreArgs ?? this.RestoreArgs, args ?? this.Args ); @@ -200,6 +206,11 @@ private ICommand GetRunCommand() globalProperties.Add("TargetFramework", Framework); } + if (!string.IsNullOrWhiteSpace(ExecutingRuntime)) + { + globalProperties.Add("ExecutingRuntime", ExecutingRuntime); + } + var project = new ProjectInstance(Project, globalProperties, null); string runProgram = project.GetPropertyValue("RunCommand"); diff --git a/src/dotnet/commands/dotnet-run/RunCommandParser.cs b/src/dotnet/commands/dotnet-run/RunCommandParser.cs index ea90555af1..849b2d5172 100644 --- a/src/dotnet/commands/dotnet-run/RunCommandParser.cs +++ b/src/dotnet/commands/dotnet-run/RunCommandParser.cs @@ -28,6 +28,7 @@ public static Command Run() => noLaunchProfile: o.HasOption("--no-launch-profile"), noRestore: o.HasOption("--no-restore") || o.HasOption("--no-build"), restoreArgs: o.OptionValuesToBeForwarded(), + executingRuntime: GetRuntimeName(o.SingleArgumentOrDefault("--clr")), args: o.Arguments )), options: new[] @@ -52,7 +53,24 @@ public static Command Run() => LocalizableStrings.CommandOptionNoBuildDescription, Accept.NoArguments()), CommonOptions.NoRestoreOption(), - CommonOptions.VerbosityOption() + CommonOptions.VerbosityOption(), + Create.Option( + "--clr", + LocalizableStrings.CommandOptionCLRDescription, + Accept.AnyOneOf("coreclr", "mono").With(name: LocalizableStrings.CommandOptionCLRName)) }); + + static string GetRuntimeName(string option) + { + switch (option) + { + case "mono": + return "mono"; + case "coreclr": + return "dotnet"; + default: + return ""; + } + } } } \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf index a3bdbef06d..62719dd750 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf @@ -144,6 +144,14 @@ Aktuální {1} je {2}. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.de.xlf index 3fc4cfe760..ee63deb2f2 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.de.xlf @@ -144,6 +144,14 @@ Ein ausführbares Projekt sollte ein ausführbares TFM (z.B. netcoreapp2.0) verw The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.es.xlf index b33b8fa21a..8273296fd0 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.es.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.es.xlf @@ -144,6 +144,14 @@ El actual {1} es "{2}". The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.fr.xlf index e82441b911..c2f010ef74 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.fr.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.fr.xlf @@ -144,6 +144,14 @@ Le {1} actuel est '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.it.xlf index 1c51f29c64..f6717a008a 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.it.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.it.xlf @@ -144,6 +144,14 @@ Il valore corrente di {1} è '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ja.xlf index 6dbca68aa4..f2161f6671 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ja.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ja.xlf @@ -144,6 +144,14 @@ The current {1} is '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ko.xlf index d6789678d0..db27049734 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ko.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ko.xlf @@ -144,6 +144,14 @@ The current {1} is '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pl.xlf index 72eb9e8909..5a91e63b13 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pl.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pl.xlf @@ -144,6 +144,14 @@ Bieżący element {1}: „{2}”. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pt-BR.xlf index 7f7bc7beab..7505f17a2f 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pt-BR.xlf @@ -144,6 +144,14 @@ O {1} atual é '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ru.xlf index cede6cc8d5..b061dfb48d 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ru.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ru.xlf @@ -144,6 +144,14 @@ The current {1} is '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.tr.xlf index df0c2eda74..c0ea26e671 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.tr.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.tr.xlf @@ -144,6 +144,14 @@ Geçerli {1}: '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hans.xlf index 5a0159f06c..48048b67ec 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hans.xlf @@ -144,6 +144,14 @@ The current {1} is '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME diff --git a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hant.xlf index e91ad3d1b7..45e2575fdc 100644 --- a/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.zh-Hant.xlf @@ -144,6 +144,14 @@ The current {1} is '{2}'. The target framework to run for. The target framework must also be specified in the project file. The target framework to run for. The target framework must also be specified in the project file. + + The execution runtime to run the .NET application with. + The execution runtime to run the .NET application with. + + + + RUNTIME + RUNTIME