Link() публичный статический Метод

public static Link ( Context context ) : int
context Context
Результат int
Пример #1
0
        private static int Main(string[] args)
        {
#if DEBUG
            LogManager.AddDebugListener(true);
#endif

            var consoleLogListener = new OutputLogListener();
            LogManager.AddListener(consoleLogListener);

            Uri        remoteGitUrl = null;
            string     commitId     = null;
            string     baseDir      = null;
            string     pdbPath      = null;
            bool       skipVerify   = false;
            LinkMethod method       = LinkMethod.Http;
            var        arguments    = ArgumentSyntax.Parse(args, syntax =>
            {
                syntax.DefineOption("m|method", ref method, v => (LinkMethod)Enum.Parse(typeof(LinkMethod), v, true), "The method for SRCSRV to retrieve source code. One of <" + string.Join("|", Enum.GetNames(typeof(LinkMethod))) + ">. Default is " + method + ".");
                syntax.DefineOption("u|url", ref remoteGitUrl, s => new Uri(s, UriKind.Absolute), "Url to remote git repository.");
                syntax.DefineOption("commit", ref commitId, "The git ref to assume all the source code belongs to.");
                syntax.DefineOption("baseDir", ref baseDir, "The path to the root of the git repo.");
                syntax.DefineOption("s|skipVerify", ref skipVerify, "Verify all source files are available in source control.");
                syntax.DefineParameter("pdb", ref pdbPath, "The PDB to add source indexing to.");

                if (!string.IsNullOrEmpty(pdbPath) && !File.Exists(pdbPath))
                {
                    syntax.ReportError($"File not found: \"{pdbPath}\"");
                }

                if (!string.IsNullOrEmpty(baseDir) && !Directory.Exists(baseDir))
                {
                    syntax.ReportError($"Directory not found: \"{baseDir}\"");
                }
            });

            if (string.IsNullOrEmpty(pdbPath))
            {
                Log.Info(arguments.GetHelpText());
                return(1);
            }

            var options = new LinkOptions
            {
                GitRemoteUrl        = remoteGitUrl,
                GitWorkingDirectory = baseDir != null?Catel.IO.Path.GetFullPath(baseDir, Environment.CurrentDirectory) : null,
                                          CommitId   = commitId,
                                          SkipVerify = skipVerify,
                                          Method     = method,
            };

            if (!Linker.Link(pdbPath, options))
            {
                return(1);
            }

            WaitForKeyPressWhenDebugging();
            return(0);
        }
Пример #2
0
        private static int Main(string[] args)
        {
#if DEBUG
            LogManager.AddDebugListener(true);
#endif

            var consoleLogListener = new OutputLogListener();
            LogManager.AddListener(consoleLogListener);

            try
            {
                HelpWriter.WriteAppHeader(s => Log.Write(LogEvent.Info, s));

                Log.Info("Arguments: {0}", string.Join(" ", args));
                Log.Info(string.Empty);

                var context = ArgumentParser.ParseArguments(args);
                if (context.IsHelp)
                {
                    HelpWriter.WriteHelp(s => Log.Write(LogEvent.Info, s));

                    WaitForKeyPress();

                    return(0);
                }

                consoleLogListener.IsDebugEnabled = context.IsDebug;

                var result = Linker.Link(context);

#if DEBUG
                WaitForKeyPress();
#endif

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "An unexpected error occurred");

#if DEBUG
                WaitForKeyPress();
#endif

                return(-1);
            }
        }