예제 #1
0
        public void Execute(string[] args)
        {
            string  packageId;
            Version packageVersion;
            string  packageSource;
            string  applicationInstallationDir;

            switch (args[1])
            {
            case "--filepath":
                packageSource = Path.GetDirectoryName(args[2]);
                string nugetPackage = Path.GetFileNameWithoutExtension(args[2]);
                var    match        = System.Text.RegularExpressions.Regex.Match(nugetPackage, @"(.*)\.([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)*)");
                packageId      = match.Groups[1].Value;
                packageVersion = new Version(match.Groups[2].Value);

                try
                {
                    applicationInstallationDir = args[3];
                }
                catch (IndexOutOfRangeException e)
                {
                    throw new InvalidOperationException("Target directory was not specified. it will be read from registry later but now you have to add an argument for it :)", e);
                }
                break;

            default:
                packageId      = args[1];
                packageVersion = new Version(args[2]);
                packageSource  = args[3];
                try
                {
                    applicationInstallationDir = args[4];
                }
                catch (IndexOutOfRangeException e)
                {
                    throw new InvalidOperationException("Target directory was not specified. it will be read from registry later but now you have to add an argument for it :)", e);
                }
                break;
            }

            HoneyInstallLocation        honeyInstallLocation       = new HoneyInstallLocation();
            IDeploymentComponentFactory deploymentComponentFactory = new DeploymentComponentFactory(honeyInstallLocation, new PathInstallLocation(applicationInstallationDir));

            INugetPackageRepository nugetPackageRepository = new NugetPackageRepository(new NugetPackageRepositoryConfig(honeyInstallLocation), new PackageSourceRepositoryFactory());
            IPackageListRepository  packageListRepository  = new PackageListRepository(new HoneyInstallLocation(), null);
            IDeploymentController   deploymentController   = new DeploymentController(logger, deploymentComponentFactory, nugetPackageRepository, packageListRepository);

            deploymentController.Upgrade(packageId, packageVersion, packageSource);
        }
예제 #2
0
파일: Program.cs 프로젝트: KinNeko-De/Honey
        private static Microsoft.Extensions.Logging.ILogger EnsureLoggerExists(Microsoft.Extensions.Logging.ILogger logger)
        {
            if (logger == null)
            {
                HoneyInstallLocation honeyInstallLocation = new HoneyInstallLocation();
                string logFile = Path.Combine(honeyInstallLocation.GetInstallLocation(), "honey.log");

                Stopwatch stopwatch = Stopwatch.StartNew();
                Serilog.Log.Logger = new Serilog.LoggerConfiguration()
                                     .MinimumLevel.Information()                                               // because filtering over loggerfactory does not work
                                     .MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Warning) // because filtering over loggerfactory does not work
                                     .MinimumLevel.Override("System", Serilog.Events.LogEventLevel.Warning)    // because filtering over loggerfactory does not work
                                     .MinimumLevel.Override("Honey", Serilog.Events.LogEventLevel.Debug)       // because filtering over loggerfactory does not work
                                     .Enrich.FromLogContext()
                                     .WriteTo.File(logFile)
                                     .CreateLogger();

                var loggerFactory = LoggerFactory.Create(builder =>
                {
                    builder
                    .SetMinimumLevel(LogLevel.Debug)                             // does not work for serilog
                    .AddSerilog(dispose: true)
                    .AddConsole()
                    .AddDebug()
                    .AddFilter("Microsoft", LogLevel.Warning)                       // does not work for serilog
                    .AddFilter("System", LogLevel.Warning)                          // does not work for serilog
                    .AddFilter("Honey", LogLevel.Debug)                             // does not work for serilog
                    .AddFilter <ConsoleLoggerProvider>("Honey", LogLevel.Information)
                    ;
                });
                logger = loggerFactory.CreateLogger <Program>();
                stopwatch.Stop();
                logger.LogDebug("Creating of Logger needed {0} ms.", stopwatch.ElapsedMilliseconds);
            }

            return(logger);
        }