Example #1
0
        private IPackageLookup GetPackageLookup()
        {
            var kernel = new LightweightKernel();

            kernel.BindAll();
            return(kernel.Get <IPackageLookup>());
        }
Example #2
0
 public static void BindCore(this LightweightKernel kernel)
 {
     kernel.Bind <IActionDispatch, ActionDispatch>();
     kernel.Bind <IHostPlatformDetector, HostPlatformDetector>();
     kernel.Bind <ILogger, Logger>();
     kernel.Bind <IWorkingDirectoryProvider, WorkingDirectoryProvider>();
 }
        private LightweightKernel GetKernel(bool noFeaturePropagation = false)
        {
            var kernel = new LightweightKernel();

            kernel.BindAll();
            return(kernel);
        }
Example #4
0
 public static void BindPackages(this LightweightKernel kernel)
 {
     kernel.Bind <IAutomaticModulePackager, AutomaticModulePackager>();
     kernel.Bind <IDeduplicator, Deduplicator>();
     kernel.Bind <IPackageCache, PackageCache>();
     kernel.Bind <IPackageRetrieval, PackageRetrieval>();
     kernel.Bind <IPackageManager, PackageManager>();
     kernel.Bind <IPackageLookup, PackageLookup>();
     kernel.Bind <IPackageCacheConfiguration, PackageCacheConfiguration>();
     kernel.BindAndKeepInstance <IPackageRedirector, PackageRedirector>();
     kernel.Bind <IPackageLocator, PackageLocator>();
 }
Example #5
0
 public ActionDispatch(
     LightweightKernel lightweightKernel,
     IHostPlatformDetector hostPlatformDetector,
     IPackageManager packageManager,
     IModuleUtilities moduleUtilities,
     IFeatureManager featureManager)
 {
     this.m_LightweightKernel = lightweightKernel;
     this.m_HostPlatformDetector = hostPlatformDetector;
     this.m_PackageManager = packageManager;
     _moduleUtilities = moduleUtilities;
     _featureManager = featureManager;
 }
Example #6
0
        private LightweightKernel GetKernel(bool noFeaturePropagation = false)
        {
            var kernel = new LightweightKernel();

            kernel.Bind <IFeatureManager, FeatureManager>();
            if (noFeaturePropagation)
            {
                kernel.Bind <IModuleExecution, MockModuleExecutionNoFeatureSupport>();
            }
            else
            {
                kernel.Bind <IModuleExecution, MockModuleExecution>();
            }
            return(kernel);
        }
Example #7
0
 public static void BindGeneration(this LightweightKernel kernel)
 {
     kernel.Bind <IExcludedServiceAwareProjectDetector, ExcludedServiceAwareProjectDetector>();
     kernel.Bind <IExternalProjectReferenceResolver, ExternalProjectReferenceResolver>();
     kernel.Bind <IContentProjectGenerator, ContentProjectGenerator>();
     kernel.Bind <INuGetConfigMover, NuGetConfigMover>();
     kernel.Bind <INuGetReferenceDetector, NuGetReferenceDetector>();
     kernel.Bind <INuGetRepositoriesConfigGenerator, NuGetRepositoriesConfigGenerator>();
     kernel.Bind <IProjectGenerator, ProjectGenerator>();
     kernel.Bind <IProjectInputGenerator, ProjectInputGenerator>();
     kernel.Bind <IProjectLoader, ProjectLoader>();
     kernel.Bind <IServiceInputGenerator, ServiceInputGenerator>();
     kernel.Bind <IServiceReferenceTranslator, ServiceReferenceTranslator>();
     kernel.Bind <ISolutionGenerator, SolutionGenerator>();
     kernel.Bind <ISolutionInputGenerator, SolutionInputGenerator>();
 }
Example #8
0
 public static void BindFileFilter(this LightweightKernel kernel)
 {
     kernel.Bind <IFileFilterParser, FileFilterParser>();
 }
Example #9
0
 public static void BindTargets(this LightweightKernel kernel)
 {
     kernel.Bind <ILanguageStringProvider, LanguageStringProvider>();
 }
Example #10
0
 public static void BindJSIL(this LightweightKernel kernel)
 {
     kernel.Bind <IJSILProvider, JSILProvider>();
 }
Example #11
0
 public static void BindBuildResources(this LightweightKernel kernel)
 {
     kernel.Bind <IResourceProvider, ResourceProvider>();
 }
Example #12
0
        public static void Main(string[] args)
        {
            // Ensure we always use the invariant culture in Protobuild.
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var kernel = new LightweightKernel();
            kernel.BindCore();
            kernel.BindBuildResources();
            kernel.BindGeneration();
            kernel.BindJSIL();
            kernel.BindTargets();
            kernel.BindFileFilter();
            kernel.BindPackages();

            var commandMappings = new Dictionary<string, ICommand>
            {
                { "sync", kernel.Get<SyncCommand>() },
                { "resync", kernel.Get<ResyncCommand>() },
                { "generate", kernel.Get<GenerateCommand>() },
                { "clean", kernel.Get<CleanCommand>() },
                { "extract-xslt", kernel.Get<ExtractXSLTCommand>() },
                { "enable", kernel.Get<EnableServiceCommand>() },
                { "disable", kernel.Get<DisableServiceCommand>() },
                { "spec", kernel.Get<ServiceSpecificationCommand>() },
                { "add", kernel.Get<AddPackageCommand>() },
                { "pack", kernel.Get<PackPackageCommand>() },
                { "format", kernel.Get<FormatPackageCommand>() },
                { "push", kernel.Get<PushPackageCommand>() },
                { "resolve", kernel.Get<ResolveCommand>() },
                { "swap-to-source", kernel.Get<SwapToSourceCommand>() },
                { "swap-to-binary", kernel.Get<SwapToBinaryCommand>() },
                { "start", kernel.Get<StartCommand>() },
            };

            var execution = new Execution();
            execution.CommandToExecute = kernel.Get<DefaultCommand>();

            var options = new Options();
            foreach (var kv in commandMappings)
            {
                var key = kv.Key;
                var value = kv.Value;

                if (value.GetArgCount() == 0)
                {
                    options[key] = x => { value.Encounter(execution, x); };
                }
                else
                {
                    options[key + "@" + value.GetArgCount()] = x => { value.Encounter(execution, x); };
                }
            }

            Action<string[]> helpAction = x =>
            {
                PrintHelp(commandMappings);
                Environment.Exit(0);
            };
            options["help"] = helpAction;
            options["?"] = helpAction;

            try
            {
                options.Parse(args);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
                PrintHelp(commandMappings);
                Environment.Exit(1);
            }

            try
            {
                var exitCode = execution.CommandToExecute.Execute(execution);
                Environment.Exit(exitCode);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Environment.Exit(1);
            }
        }
Example #13
0
        public static void Main(string[] args)
        {
            // Ensure we always use the invariant culture in Protobuild.
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Set our SSL trust policy.  Because Mono doesn't ship with root certificates
            // on most Linux distributions, we have to be a little more insecure here than
            // I'd like.  For protobuild.org we always verify that the root of the certificate
            // chain matches what we expect (so people can't forge a certificate from a
            // *different CA*), but for other domains we just have to implicitly trust them
            // on Linux since we have no root store.
            if (Path.DirectorySeparatorChar == '/' && !Directory.Exists("/Library"))
            {
                ServicePointManager.ServerCertificateValidationCallback = SSLValidationForLinux;
            }

            var kernel = new LightweightKernel();
            kernel.BindCore();
            kernel.BindBuildResources();
            kernel.BindGeneration();
            kernel.BindJSIL();
            kernel.BindTargets();
            kernel.BindFileFilter();
            kernel.BindPackages();
            kernel.BindAutomatedBuild();

            var featureManager = kernel.Get<IFeatureManager>();
            featureManager.LoadFeaturesForCurrentDirectory();

            var commandMappings = new Dictionary<string, ICommand>
            {
                { "sync", kernel.Get<SyncCommand>() },
                { "resync", kernel.Get<ResyncCommand>() },
                { "generate", kernel.Get<GenerateCommand>() },
                { "build", kernel.Get<BuildCommand>() },
                { "build-target", kernel.Get<BuildTargetCommand>() },
                { "build-property", kernel.Get<BuildPropertyCommand>() },
                { "build-process-arch", kernel.Get<BuildProcessArchCommand>() },
                { "clean", kernel.Get<CleanCommand>() },
                { "automated-build", kernel.Get<AutomatedBuildCommand>() },
                { "extract-xslt", kernel.Get<ExtractXSLTCommand>() },
                { "enable", kernel.Get<EnableServiceCommand>() },
                { "disable", kernel.Get<DisableServiceCommand>() },
                { "debug-service-resolution", kernel.Get<DebugServiceResolutionCommand>() },
                { "simulate-host-platform", kernel.Get<SimulateHostPlatformCommand>() },
                { "spec", kernel.Get<ServiceSpecificationCommand>() },
                { "query-features", kernel.Get<QueryFeaturesCommand>() },
                { "features", kernel.Get<FeaturesCommand>() },
                { "add", kernel.Get<AddPackageCommand>() },
                { "list", kernel.Get<ListPackagesCommand>() },
                { "install", kernel.Get<InstallPackageCommand>() },
                { "upgrade", kernel.Get<UpgradePackageCommand>() },
                { "upgrade-all", kernel.Get<UpgradeAllPackagesCommand>() },
                { "pack", kernel.Get<PackPackageCommand>() },
                { "format", kernel.Get<FormatPackageCommand>() },
                { "push", kernel.Get<PushPackageCommand>() },
                { "ignore-on-existing", kernel.Get<IgnoreOnExistingPackageCommand>() },
                { "repush", kernel.Get<RepushPackageCommand>() },
                { "resolve", kernel.Get<ResolveCommand>() },
                { "no-resolve", kernel.Get<NoResolveCommand>() },
                { "redirect", kernel.Get<RedirectPackageCommand>() },
                { "swap-to-source", kernel.Get<SwapToSourceCommand>() },
                { "swap-to-binary", kernel.Get<SwapToBinaryCommand>() },
                { "start", kernel.Get<StartCommand>() },
                { "no-generate", kernel.Get<NoGenerateCommand>() },
                { "no-host-generate", kernel.Get<NoHostGenerateCommand>() },
                { "execute", kernel.Get<ExecuteCommand>() },
                { "execute-configuration", kernel.Get<ExecuteConfigurationCommand>() },
            };

            var execution = new Execution();
            execution.CommandToExecute = kernel.Get<DefaultCommand>();

            var options = new Options();
            foreach (var kv in commandMappings)
            {
                var key = kv.Key;
                var value = kv.Value;

                Action<string[]> handle = x =>
                {
                    if (value.IsRecognised())
                    {
                        value.Encounter(execution, x);
                    }
                    else if (value.IsIgnored())
                    {
                    }
                    else
                    {
                        throw new InvalidOperationException("Unknown argument '" + key + "'");
                    }
                };

                if (value.GetArgCount() == 0)
                {
                    options[key] = handle;
                }
                else
                {
                    options[key + "@" + value.GetArgCount()] = handle;
                }
            }

            Action<string[]> helpAction = x =>
            {
                PrintHelp(commandMappings);
                ExecEnvironment.Exit(0);
            };
            options["help"] = helpAction;
            options["?"] = helpAction;

            if (ExecEnvironment.DoNotWrapExecutionInTry)
            {
                options.Parse(args);
            }
            else
            {
                try
                {
                    options.Parse(args);
                }
                catch (InvalidOperationException ex)
                {
                    Console.WriteLine(ex.Message);
                    PrintHelp(commandMappings);
                    ExecEnvironment.Exit(1);
                }
            }

            featureManager.ValidateEnabledFeatures();

            if (ExecEnvironment.DoNotWrapExecutionInTry)
            {
                var exitCode = execution.CommandToExecute.Execute(execution);
                ExecEnvironment.Exit(exitCode);
            }
            else
            {
                try
                {
                    var exitCode = execution.CommandToExecute.Execute(execution);
                    ExecEnvironment.Exit(exitCode);
                }
                catch (ExecEnvironment.SelfInvokeExitException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    ExecEnvironment.Exit(1);
                }
            }
        }
 private LightweightKernel GetKernel(bool noFeaturePropagation = false)
 {
     var kernel = new LightweightKernel();
     kernel.Bind<IFeatureManager, FeatureManager>();
     if (noFeaturePropagation)
     {
         kernel.Bind<IModuleExecution, MockModuleExecutionNoFeatureSupport>();
     }
     else
     {
         kernel.Bind<IModuleExecution, MockModuleExecution>();
     }
     return kernel;
 }
 private IPackageLookup GetPackageLookup()
 {
     var kernel = new LightweightKernel();
     kernel.BindAll();
     return kernel.Get<IPackageLookup>();
 }