Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Allows .NET Core apps to be optionally run using the Mono runtime
Browse files Browse the repository at this point in the history
Fixes #6043
  • Loading branch information
marek-safar committed May 25, 2018
1 parent 6f6f28d commit ffcf6e8
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/dotnet/commands/dotnet-run/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@
</data>
<data name="FrameworkOptionDescription" xml:space="preserve">
<value>The target framework to run for. The target framework must also be specified in the project file.</value>
<data name="CommandOptionCLRDescription" xml:space="preserve">
<value>The execution runtime to run the .NET application with.</value>
</data>
<data name="CommandOptionCLRName" xml:space="preserve">
<value>RUNTIME</value>
</data>
<data name="RunCommandException" xml:space="preserve">
<value>The build failed. Please fix the build errors and run again.</value>
Expand Down
11 changes: 11 additions & 0 deletions src/dotnet/commands/dotnet-run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -69,6 +71,7 @@ public RunCommand(string configuration,
string launchProfile,
bool noLaunchProfile,
bool noRestore,
string executingRuntime,
IEnumerable<string> restoreArgs,
IReadOnlyCollection<string> args)
{
Expand All @@ -81,6 +84,7 @@ public RunCommand(string configuration,
Args = args;
RestoreArgs = restoreArgs;
NoRestore = noRestore;
ExecutingRuntime = executingRuntime;
}

public RunCommand MakeNewWithReplaced(string configuration = null,
Expand All @@ -90,6 +94,7 @@ public RunCommand MakeNewWithReplaced(string configuration = null,
string launchProfile = null,
bool? noLaunchProfile = null,
bool? noRestore = null,
string executingRuntime = null,
IEnumerable<string> restoreArgs = null,
IReadOnlyCollection<string> args = null)
{
Expand All @@ -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
);
Expand Down Expand Up @@ -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");
Expand Down
20 changes: 19 additions & 1 deletion src/dotnet/commands/dotnet-run/RunCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand All @@ -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 "";
}
}
}
}
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ Aktuální {1} je {2}.</target>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ Ein ausführbares Projekt sollte ein ausführbares TFM (z.B. netcoreapp2.0) verw
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ El actual {1} es "{2}".</target>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ Le {1} actuel est '{2}'.</target>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ Il valore corrente di {1} è '{2}'.</target>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ The current {1} is '{2}'.</source>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ The current {1} is '{2}'.</source>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ Bieżący element {1}: „{2}”.</target>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ O {1} atual é '{2}'.</target>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ The current {1} is '{2}'.</source>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet/commands/dotnet-run/xlf/LocalizableStrings.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ Geçerli {1}: '{2}'.</target>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ The current {1} is '{2}'.</source>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ The current {1} is '{2}'.</source>
<trans-unit id="FrameworkOptionDescription">
<source>The target framework to run for. The target framework must also be specified in the project file.</source>
<target state="new">The target framework to run for. The target framework must also be specified in the project file.</target>
<trans-unit id="CommandOptionCLRDescription">
<source>The execution runtime to run the .NET application with.</source>
<target state="new">The execution runtime to run the .NET application with.</target>
<note />
</trans-unit>
<trans-unit id="CommandOptionCLRName">
<source>RUNTIME</source>
<target state="new">RUNTIME</target>
<note />
</trans-unit>
</body>
Expand Down

0 comments on commit ffcf6e8

Please sign in to comment.