Пример #1
0
        private int InvokeAsExternalProcess(string rhetosHostDllPath, string[] baseArgs)
        {
            var newArgs = new List <string>(baseArgs);

            newArgs.Add(ExecuteCommandInCurrentProcessOptionName);
            return(Exe.RunWithHostConfiguration(GetType().Assembly.Location, rhetosHostDllPath, newArgs, _logger));
        }
Пример #2
0
        public static int RunWithHostConfiguration(
            string executable,
            string hostFilePath,
            IReadOnlyList <string> baseArgs,
            ILogger logger = null)
        {
            var newArgs = new List <string>();

            newArgs.Add("exec");

            var runtimeConfigPath = Path.ChangeExtension(hostFilePath, "runtimeconfig.json");

            if (!File.Exists(runtimeConfigPath))
            {
                logger?.Error($"Missing {runtimeConfigPath} file required to run the AdminSetup program.");
                return(1);
            }

            newArgs.Add("--runtimeconfig");
            newArgs.Add(runtimeConfigPath);

            var depsFile = Path.ChangeExtension(hostFilePath, "deps.json");

            if (File.Exists(depsFile))
            {
                newArgs.Add("--depsfile");
                newArgs.Add(depsFile);
            }
            else
            {
                logger?.Warning($"The file {depsFile} was not found. This can cause a 'DllNotFoundException' during the program execution.");
            }

            newArgs.Add(executable);
            newArgs.AddRange(baseArgs);

            logger?.Trace(() => "dotnet args: " + string.Join(", ", newArgs.Select(arg => "\"" + (arg ?? "null") + "\"")));
            return(Exe.Run("dotnet", newArgs));
        }