Example #1
0
    unsafe static int Execute(int argc, char **argv, NativeBootstrapperContext *context)
    {
        Logger.TraceInformation($"[{nameof(DomainManager)}] Using CoreCLR");

        // Pack arguments
        var arguments = new string[argc];

        for (var i = 0; i < arguments.Length; i++)
        {
            arguments[i] = new string(argv[i]);
        }

        try
        {
            var bootstrapperContext = new BootstrapperContext();

            bootstrapperContext.OperatingSystem  = new string(context->OperatingSystem);
            bootstrapperContext.OsVersion        = new string(context->OsVersion);
            bootstrapperContext.Architecture     = new string(context->Architecture);
            bootstrapperContext.RuntimeDirectory = new string(context->RuntimeDirectory);
            bootstrapperContext.ApplicationBase  = new string(context->ApplicationBase);
            bootstrapperContext.TargetFramework  = new FrameworkName(FrameworkNames.LongNames.DnxCore, new Version(5, 0));
            bootstrapperContext.RuntimeType      = "CoreClr";

            return(RuntimeBootstrapper.Execute(arguments, bootstrapperContext));
        }
        catch (Exception ex)
        {
            return(ex.HResult != 0 ? ex.HResult : 1);
        }
    }
Example #2
0
 public RuntimeEnvironment(BootstrapperContext bootstrapperContext)
 {
     RuntimeType            = bootstrapperContext.RuntimeType;
     RuntimeArchitecture    = bootstrapperContext.Architecture;
     OperatingSystem        = bootstrapperContext.OperatingSystem;
     OperatingSystemVersion = bootstrapperContext.OsVersion;
 }
Example #3
0
        public EngineHost(BootstrapperContext bootstrapper)
        {
            if (bootstrapper == null)
            {
                throw new ArgumentNullException(nameof(bootstrapper));
            }

            _bootstrapper = bootstrapper;
        }
Example #4
0
        public RuntimeEnvironment(BootstrapperContext bootstrapperContext)
        {
            // Use the DefaultRuntimeEnvironment to detect the OS details rather than bootstrapper context (temporary, this is probably going away anyway)
            var defaultEnv = new DefaultRuntimeEnvironment();

            OperatingSystem         = defaultEnv.OperatingSystem;
            OperatingSystemVersion  = defaultEnv.OperatingSystemVersion;
            OperatingSystemPlatform = defaultEnv.OperatingSystemPlatform;

            RuntimeType         = bootstrapperContext.RuntimeType;
            RuntimeArchitecture = bootstrapperContext.Architecture;
            RuntimePath         = bootstrapperContext.RuntimeDirectory;
        }
Example #5
0
    public static int Main(string[] arguments)
    {
        // Check for the debug flag before doing anything else
        bool hasDebugWaitFlag = false;

        for (var i = 0; i < arguments.Length; ++i)
        {
            //anything without - or -- is appbase or non-dnx command
            if (arguments[i][0] != '-')
            {
                break;
            }
            if (arguments[i] == "--appbase")
            {
                //skip path argument
                ++i;
                continue;
            }
            if (arguments[i] == "--debug")
            {
                hasDebugWaitFlag = true;
                break;
            }
        }

        if (hasDebugWaitFlag)
        {
            if (!Debugger.IsAttached)
            {
                Process currentProc = Process.GetCurrentProcess();
                Console.WriteLine("Process Id: {0}", currentProc.Id);
                Console.WriteLine("Waiting for the debugger to attach...");

                while (!Debugger.IsAttached)
                {
                    Thread.Sleep(250);
                }

                Console.WriteLine("Debugger attached.");
            }
        }

        arguments = ExpandCommandLineArguments(arguments);

        // Set application base dir
        var appbaseIndex = arguments.ToList().FindIndex(arg =>
                                                        string.Equals(arg, "--appbase", StringComparison.OrdinalIgnoreCase));

        var appBase = appbaseIndex >= 0 && (appbaseIndex < arguments.Length - 1)
                ? arguments[appbaseIndex + 1]
                : Directory.GetCurrentDirectory();

        string operatingSystem, osVersion, architecture;

        GetOsDetails(out operatingSystem, out osVersion, out architecture);

        var bootstrapperContext = new BootstrapperContext
        {
            OperatingSystem  = operatingSystem,
            OsVersion        = osVersion,
            Architecture     = architecture,
            RuntimeDirectory = Path.GetDirectoryName(typeof(EntryPoint).Assembly.Location),
            ApplicationBase  = appBase,
            // NOTE(anurse): Mono is always "dnx451" (for now).
            TargetFramework = new FrameworkName("DNX", new Version(4, 5, 1)),
            RuntimeType     = "Mono"
        };

        return(RuntimeBootstrapper.Execute(arguments, bootstrapperContext));
    }
Example #6
0
 /// <summary>
 /// Creates a new bootstrapper.
 /// </summary>
 /// <param name="program">A path to the program.</param>
 public Bootstrapper(string program, BootstrapperContext context) =>
 (m_context, m_program, m_arguments, m_builder) =