public override void Invoke() { if (NetFx || NetCore) { string name = NetFx ? "desktop .NET Framework" : ".NET Core"; foreach (IRuntime runtime in RuntimeService.Runtimes) { if (NetFx && runtime.RuntimeType == RuntimeType.Desktop || NetCore && runtime.RuntimeType == RuntimeType.NetCore) { RuntimeService.SetCurrentRuntime(runtime.Id); WriteLine("Switched to {0} runtime successfully", name); return; } } WriteLineError("The {0} runtime is not loaded", name); } else { foreach (IRuntime runtime in RuntimeService.Runtimes) { string current = RuntimeService.Runtimes.Count() > 1 ? runtime == RuntimeService.CurrentRuntime ? "*" : " " : ""; Write(current); Write(runtime.ToString()); } } }
public override void Invoke() { if (NetFx && NetCore) { throw new DiagnosticsException("Cannot specify both -netfx and -netcore options"); } if (NetFx || NetCore) { string name = NetFx ? "desktop .NET Framework" : ".NET Core"; foreach (IRuntime runtime in RuntimeService.EnumerateRuntimes()) { if (NetFx && runtime.RuntimeType == RuntimeType.Desktop || NetCore && runtime.RuntimeType == RuntimeType.NetCore) { RuntimeService.SetCurrentRuntime(runtime.Id); WriteLine("Switched to {0} runtime successfully", name); return; } } WriteLineError("The {0} runtime is not loaded", name); } else { // Display the current runtime star ("*") only if there is more than one runtime bool displayStar = RuntimeService.EnumerateRuntimes().Count() > 1; foreach (IRuntime runtime in RuntimeService.EnumerateRuntimes()) { string current = displayStar ? (runtime == RuntimeService.CurrentRuntime ? "*" : " ") : ""; Write(current); Write(runtime.ToString()); } } }