Exemplo n.º 1
0
        static void Main(string[] args)
        {
            bool hideConsole = false;

            if (args.Contains("-noconsole"))
            {
                hideConsole = true;
                args        = args.Where(a => a != "-noconsole").ToArray();
            }

            if (args.Contains("-nc"))
            {
                hideConsole = true;
                args        = args.Where(a => a != "-nc").ToArray();
            }

            var arguments = new List <string>();

            arguments.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cscs.dll"));
            arguments.AddRange(args);

            var combinedArgs = arguments.Select(x => (x.Contains(" ") || x.Contains("\t")) ? $"\"{x}\"" : x)
                               .ToArray();

            // ScriptLauncher.ShowConsole(); // interferes with Conspole.ReadKey

            if (hideConsole)
            {
                ScriptLauncher.HideConsole();
            }

            ScriptLauncher.Run("dotnet", string.Join(" ", combinedArgs));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Environment.SetEnvironmentVariable("CSS_WINAPP", "true", EnvironmentVariableTarget.User);
            Environment.SetEnvironmentVariable("Console.WindowWidth", Console.WindowWidth.ToString());
            Environment.SetEnvironmentVariable("ENTRY_ASM", Assembly.GetExecutingAssembly().GetName().Name);
            bool hideConsole = false;
            bool winApp      = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CSS_WINAPP"));

            if (args.Contains("-win"))
            {
                winApp = true;
                args   = args.Where(x => x != "-win").ToArray();
            }

            if (args.Contains("-noconsole") || args.Contains("-nc"))
            {
                hideConsole = true;
                args        = args.Where(a => a != "-noconsole" && a != "-nc").ToArray();
            }

            var host      = "dotnet";
            var arguments = new List <string>(args);

            if (ConfiguredFullDotNetLauncher != null)
            {
                if (Environment.OSVersion.IsWin())
                {
                    host = ConfiguredFullDotNetLauncher;
                }
                else
                {
                    host = "mono";
                    arguments.Insert(0, ConfiguredFullDotNetLauncher);
                }
            }
            else
            {
                host = "dotnet";
                var engine = "cscs.dll";
                if (winApp)
                {
                    engine = "csws.dll";
                }
                arguments.Insert(0, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), engine));
            }

            // ScriptLauncher.ShowConsole(); // interferes with Conspole.ReadKey

            if (hideConsole)
            {
                ScriptLauncher.HideConsole();
            }

            ScriptLauncher.Run(host, arguments.ToCmdArgs());
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Environment.SetEnvironmentVariable("Console.WindowWidth", Console.WindowWidth.ToString());
            bool hideConsole = false;

            if (args.Contains("-noconsole") || args.Contains("-nc"))
            {
                hideConsole = true;
                args        = args.Where(a => a != "-noconsole" && a != "-nc").ToArray();
            }

            if (args.ParseValuedArg("runtime", "rt", out string value))
            {
                var full_env = Environment.OSVersion.IsWin() ? ".NET" : "Mono";

                args = args.Where(a => !(a.StartsWith("-engine") || a.StartsWith("-eng"))).ToArray();
                if (value == null)
                {
                    if (args.Contains("?") || args.Contains("help"))
                    {
                        Console.WriteLine("-rt|-runtime[:<core|net>]\n" +
                                          "    Sets the execution engine to .NET Core or the full version of .NET/Mono.");
                    }
                    else
                    {
                        if (File.Exists(RedirectFileName))
                        {
                            Console.WriteLine($"The execution engine is set to {full_env}");
                        }
                        else
                        {
                            Console.WriteLine($"The execution engine is set to .NET Core");
                        }
                    }
                }
                else
                {
                    switch (value.ToLower())
                    {
                    case "net":
                        File.WriteAllText(RedirectFileName, "");
                        Console.WriteLine($"The execution engine is set to {full_env}");
                        break;

                    case "core":
                        if (File.Exists(RedirectFileName))
                        {
                            File.Delete(RedirectFileName);
                        }
                        Console.WriteLine($"The execution engine is set to .NET Core");
                        break;
                    }
                }
                return;
            }

            var host      = "dotnet";
            var arguments = new List <string>(args);

            if (ConfiguredFullDotNetLauncher != null)
            {
                if (Environment.OSVersion.IsWin())
                {
                    host = ConfiguredFullDotNetLauncher;
                }
                else
                {
                    host = "mono";
                    arguments.Insert(0, ConfiguredFullDotNetLauncher);
                }
            }
            else
            {
                host = "dotnet";
                arguments.Insert(0, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cscs.dll"));
            }

            // ScriptLauncher.ShowConsole(); // interferes with Conspole.ReadKey

            if (hideConsole)
            {
                ScriptLauncher.HideConsole();
            }

            ScriptLauncher.Run(host, arguments.ToCmdArgs());
        }