Пример #1
0
        public static void BindPackages(this LightweightKernel kernel)
        {
            kernel.Bind <IAutomaticModulePackager, AutomaticModulePackager>();
            kernel.Bind <IDeduplicator, Deduplicator>();
            kernel.Bind <IPackageManager, PackageManager>();
            kernel.Bind <IPackageLookup, PackageLookup>();
            kernel.Bind <IPackageCacheConfiguration, PackageCacheConfiguration>();
            kernel.BindAndKeepInstance <IPackageRedirector, PackageRedirector>();
            kernel.Bind <IPackageLocator, PackageLocator>();
            kernel.Bind <IProjectOutputPathCalculator, ProjectOutputPathCalculator>();
            kernel.Bind <IPackageGlobalTool, PackageGlobalTool>();
            kernel.Bind <IProgressiveWebOperation, ProgressiveWebOperation>();
            kernel.Bind <IPackageCreator, PackageCreator>();
            kernel.Bind <IGetRecursiveUtilitiesInPath, GetRecursiveUtilitiesInPath>();
            kernel.Bind <IPackageUrlParser, PackageUrlParser>();
            kernel.Bind <IKnownToolProvider, KnownToolProvider>();
            kernel.Bind <IPackageNameLookup, PackageNameLookup>();
            kernel.Bind <IProjectTemplateApplier, ProjectTemplateApplier>();

            kernel.Bind <IPackageProtocol, GitPackageProtocol>();
            kernel.Bind <IPackageProtocol, LocalTemplatePackageProtocol>();
            kernel.Bind <IPackageProtocol, LocalTemplateGitPackageProtocol>();
            kernel.Bind <IPackageProtocol, NuGetPackageProtocol>();
            kernel.Bind <IPackageProtocol, ProtobuildPackageProtocol>();
            kernel.Bind <IPackageProtocol, LocalProtobuildPackageProtocol>();
        }
Пример #2
0
 public static void BindCore(this LightweightKernel kernel)
 {
     kernel.Bind <IActionDispatch, ActionDispatch>();
     kernel.Bind <IHostPlatformDetector, HostPlatformDetector>();
     kernel.Bind <ILogger, Logger>();
     kernel.BindAndKeepInstance <IModuleUtilities, ModuleUtilities>();
     kernel.BindAndKeepInstance <IModuleExecution, ModuleExecution>();
     kernel.BindAndKeepInstance <IFeatureManager, FeatureManager>();
 }
Пример #3
0
 public ActionDispatch(
     LightweightKernel lightweightKernel,
     IHostPlatformDetector hostPlatformDetector,
     IPackageManager packageManager)
 {
     this.m_LightweightKernel    = lightweightKernel;
     this.m_HostPlatformDetector = hostPlatformDetector;
     this.m_PackageManager       = packageManager;
 }
Пример #4
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;
 }
Пример #5
0
 public BinaryPackageResolve(
     SourcePackageResolve sourcePackageResolve,
     IProjectTemplateApplier projectTemplateApplier,
     IPackageGlobalTool packageGlobalTool,
     IPackageCacheConfiguration packageCacheConfiguration,
     IProgressiveWebOperation progressiveWebOperation,
     INuGetPlatformMapping nugetPlatformMapping,
     LightweightKernel lightweightKernel)
 {
     _sourcePackageResolve      = sourcePackageResolve;
     _projectTemplateApplier    = projectTemplateApplier;
     _packageGlobalTool         = packageGlobalTool;
     _packageCacheConfiguration = packageCacheConfiguration;
     _progressiveWebOperation   = progressiveWebOperation;
     _nugetPlatformMapping      = nugetPlatformMapping;
     _lightweightKernel         = lightweightKernel;
 }
Пример #6
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>();
     kernel.Bind <IPlatformResourcesGenerator, PlatformResourcesGenerator>();
     kernel.Bind <IIncludeProjectAppliesToUpdater, IncludeProjectAppliesToUpdater>();
     kernel.Bind <IIncludeProjectMerger, IncludeProjectMerger>();
 }
Пример #7
0
 public static void BindAutomatedBuild(this LightweightKernel kernel)
 {
     kernel.Bind <IAutomatedBuildController, AutomatedBuildController>();
     kernel.Bind <IAutomatedBuildRuntimeV1, AutomatedBuildRuntimeV1>();
 }
Пример #8
0
 public static void BindFileFilter(this LightweightKernel kernel)
 {
     kernel.Bind <IFileFilterParser, FileFilterParser>();
 }
Пример #9
0
 public static void BindTargets(this LightweightKernel kernel)
 {
     kernel.Bind <ILanguageStringProvider, LanguageStringProvider>();
 }
Пример #10
0
 public static void BindJSIL(this LightweightKernel kernel)
 {
     kernel.Bind <IJSILProvider, JSILProvider>();
 }
Пример #11
0
 public static void BindBuildResources(this LightweightKernel kernel)
 {
     kernel.Bind <IResourceProvider, ResourceProvider>();
     kernel.Bind <IGenerationFunctionsProvider, GenerationFunctionsProvider>();
 }
Пример #12
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);
                }
            }
        }
Пример #13
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>() },
                { "upgrade", kernel.Get <UpgradePackageCommand>() },
                { "upgrade-all", kernel.Get <UpgradeAllPackagesCommand>() },
                { "pack", kernel.Get <PackPackageCommand>() },
                { "format", kernel.Get <FormatPackageCommand>() },
                { "push", kernel.Get <PushPackageCommand>() },
                { "resolve", kernel.Get <ResolveCommand>() },
                { "redirect", kernel.Get <RedirectPackageCommand>() },
                { "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);
                ExecEnvironment.Exit(0);
            };

            options["help"] = helpAction;
            options["?"]    = helpAction;

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

            try
            {
                var exitCode = execution.CommandToExecute.Execute(execution);
                ExecEnvironment.Exit(exitCode);
            }
            catch (ExecEnvironment.SelfInvokeExitException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                ExecEnvironment.Exit(1);
            }
        }