Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                options = Args.Parse<InstallArgs>(args);
            }
            catch (ArgException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ArgUsage.GenerateUsageFromTemplate<InstallArgs>());
                return;
            }

            try
            {
                if (String.IsNullOrWhiteSpace(options.TempPath))
                {
                    options.TempPath = Path.Combine(options.InstallLocation, "_temp");
                }

                if (!Directory.Exists(options.InstallLocation))
                {
                    Directory.CreateDirectory(options.InstallLocation);
                }

                if (!Directory.Exists(options.TempPath))
                {
                    Directory.CreateDirectory(options.TempPath);
                }

                WebClient client = new WebClient();
                Console.WriteLine("Downloading file");
                var localZip = Path.Combine(options.TempPath,  "Tether.zip");
                client.DownloadFile(options.TetherLocation, localZip);
                Console.WriteLine("File Downloaded, executing");
                
                ServiceController ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == "ThreeOneThree.Tether");

                if (ctl == null)
                {
                    Console.WriteLine("Performing Fresh install");
                    PerformFreshInstall(localZip, client);
                }
                else
                {
                    Console.WriteLine("Performing Upgrade");
                    PerformUpgradeInstall(localZip, client, ctl);
                }

                Console.WriteLine("Finished");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                options = Args.Parse <InstallArgs>(args);
            }
            catch (ArgException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ArgUsage.GenerateUsageFromTemplate <InstallArgs>());
                return;
            }

            try
            {
                if (String.IsNullOrWhiteSpace(options.TempPath))
                {
                    options.TempPath = Path.Combine(options.InstallLocation, "_temp");
                }

                var serviceControllers = ServiceController.GetServices();
                CheckAndRemoveV1(serviceControllers);

                if (!Directory.Exists(options.InstallLocation))
                {
                    Console.WriteLine($"Creating installation directory {options.InstallLocation}");
                    Directory.CreateDirectory(options.InstallLocation);
                }

                if (!Directory.Exists(options.TempPath))
                {
                    Console.WriteLine($"Creating installation directory {options.TempPath}");
                    Directory.CreateDirectory(options.TempPath);
                }

                var client = new WebClient();

                Console.WriteLine("Downloading file");

                var localZip = Path.Combine(options.TempPath, "Tether.zip");
                client.DownloadFile(options.TetherLocation, localZip);

                Console.WriteLine("File Downloaded, executing");

                var ctl = serviceControllers.FirstOrDefault(s => s.ServiceName == "Tether");

                if (ctl == null)
                {
                    Console.WriteLine("Performing Fresh install");
                    PerformFreshInstall(localZip, client);
                }
                else
                {
                    Console.WriteLine("Performing Upgrade");
                    PerformUpgradeInstall(localZip, client, ctl);
                }

                Console.WriteLine("Finished");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }