Пример #1
0
        public static void Main(string[] args)
        {
            GSDPlatformLoader.Initialize();

            Parser.Default.ParseArguments <UpgradeOptions>(args)
            .WithParsed(options => UpgradeOrchestratorFactory.Create(options).Execute());
        }
Пример #2
0
        public static void Main(string[] args)
        {
            GSDPlatformLoader.Initialize();

            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

            using (JsonTracer tracer = new JsonTracer(GSDConstants.Service.ServiceName, GSDConstants.Service.ServiceName))
            {
                CreateService(tracer, args).Run();
            }
        }
Пример #3
0
 public static void Main(string[] args)
 {
     GSDPlatformLoader.Initialize();
     try
     {
         Parser.Default.ParseArguments <InProcessMountVerb>(args)
         .WithParsed(mount => mount.Execute());
     }
     catch (MountAbortedException e)
     {
         // Calling Environment.Exit() is required, to force all background threads to exit as well
         Environment.Exit((int)e.Verb.ReturnCode);
     }
 }
Пример #4
0
        public static void Main(string[] args)
        {
            GSDPlatformLoader.Initialize();

            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;

            using (JsonTracer tracer = new JsonTracer(GSDConstants.Service.ServiceName, GSDConstants.Service.ServiceName))
            {
                using (GSDService service = new GSDService(tracer))
                {
                    // This will fail with a popup from a command prompt. To install as a service, run:
                    // %windir%\Microsoft.NET\Framework64\v4.0.30319\installutil GSD.Service.exe
                    ServiceBase.Run(service);
                }
            }
        }
Пример #5
0
        public static void Main(string[] args)
        {
            GSDPlatformLoader.Initialize();

            using (JsonTracer tracer = new JsonTracer("Microsoft.Git.GSD.Service.UI", "Service.UI"))
            {
                string logLocation = Path.Combine(
                    Environment.GetEnvironmentVariable("LocalAppData"),
                    GSDConstants.Service.UIName,
                    "serviceUI.log");

                tracer.AddLogFileEventListener(logLocation, EventLevel.Informational, Keywords.Any);
                GSDServiceUI process = new GSDServiceUI(tracer);
                process.Start(args);
            }
        }
Пример #6
0
        public static void Main(string[] args)
        {
            GSDPlatformLoader.Initialize();

            Type[] verbTypes = new Type[]
            {
                typeof(CacheServerVerb),
                typeof(CloneVerb),
                typeof(ConfigVerb),
                typeof(DiagnoseVerb),
                typeof(LogVerb),
                typeof(MountVerb),
                typeof(PrefetchVerb),
                typeof(RepairVerb),
                typeof(ServiceVerb),
                typeof(StatusVerb),
                typeof(UnmountVerb),
                typeof(UpgradeVerb),
            };

            int consoleWidth = 80;

            // Running in a headless environment can result in a Console with a
            // WindowWidth of 0, which causes issues with CommandLineParser
            try
            {
                if (Console.WindowWidth > 0)
                {
                    consoleWidth = Console.WindowWidth;
                }
            }
            catch (IOException)
            {
            }

            try
            {
                new Parser(
                    settings =>
                {
                    settings.CaseSensitive          = false;
                    settings.EnableDashDash         = true;
                    settings.IgnoreUnknownArguments = false;
                    settings.HelpWriter             = Console.Error;
                    settings.MaximumDisplayWidth    = consoleWidth;
                })
                .ParseArguments(args, verbTypes)
                .WithNotParsed(
                    errors =>
                {
                    if (errors.Any(error => error is TokenError))
                    {
                        Environment.Exit((int)ReturnCode.ParsingError);
                    }
                })
                .WithParsed <CloneVerb>(
                    clone =>
                {
                    // We handle the clone verb differently, because clone cares if the enlistment path
                    // was not specified vs if it was specified to be the current directory
                    clone.Execute();
                    Environment.Exit((int)ReturnCode.Success);
                })
                .WithParsed <GSDVerb.ForNoEnlistment>(
                    verb =>
                {
                    verb.Execute();
                    Environment.Exit((int)ReturnCode.Success);
                })
                .WithParsed <GSDVerb>(
                    verb =>
                {
                    // For all other verbs, they don't care if the enlistment root is explicitly
                    // specified or implied to be the current directory
                    if (string.IsNullOrEmpty(verb.EnlistmentRootPathParameter))
                    {
                        verb.EnlistmentRootPathParameter = Environment.CurrentDirectory;
                    }

                    verb.Execute();
                    Environment.Exit((int)ReturnCode.Success);
                });
            }
            catch (GSDVerb.VerbAbortedException e)
            {
                // Calling Environment.Exit() is required, to force all background threads to exit as well
                Environment.Exit((int)e.Verb.ReturnCode);
            }
        }