/// <summary>
        /// Sets the relative working directory to be used when running the build.
        /// </summary>
        /// <param name="services">The service registration collection.</param>
        /// <param name="path">The working directory path.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseWorkingDirectory(this ICakeServices services, DirectoryPath path)
        {
            Guard.ArgumentNotNull(services, nameof(services));

            services.RegisterInstance(new WorkingDirectory(path)).AsSelf().Singleton();
            return(services);
        }
        /// <summary>
        ///  Add or replace a setting in the configuration.
        /// </summary>
        /// <param name="services">The service registration collection.</param>
        /// <param name="key">The key of the setting to add or replace.</param>
        /// <param name="value">The value of the setting to add or replace.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseSetting(this ICakeServices services, string key, string value)
        {
            var info = new ConfigurationValue(key, value);

            services.RegisterInstance(info).AsSelf().Singleton();
            return(services);
        }
        /// <summary>
        /// Registers the specified <see cref="Assembly"/>.
        /// </summary>
        /// <param name="services">The service registration collection.</param>
        /// <param name="assembly">The assembly to register.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseAssembly(this ICakeServices services, Assembly assembly)
        {
            Guard.ArgumentNotNull(services, nameof(services));

            services.RegisterInstance(assembly).Singleton();
            return(services);
        }
Пример #4
0
 public void Configure(ICakeServices services)
 {
     services.UseAssembly(typeof(Default).Assembly);
     services.UseContext <DotNetCoreContext>();
     services.UseLifetime <DotNetCoreLifetime>();
     services.UseWorkingDirectory("..");
 }
        /// <summary>
        /// Registers the specified context type.
        /// Only the last registration will be used.
        /// </summary>
        /// <typeparam name="TContext">The type of the context to register.</typeparam>
        /// <param name="services">The service registration collection.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseContext <TContext>(this ICakeServices services)
            where TContext : IFrostingContext
        {
            Guard.ArgumentNotNull(services, nameof(services));

            services.RegisterType <TContext>().AsSelf().As <IFrostingContext>().Singleton();
            return(services);
        }
        /// <summary>
        /// Registers the specified task lifetime type.
        /// Only the last registration will be used.
        /// </summary>
        /// <typeparam name="TLifetime">The type of the lifetime.</typeparam>
        /// <param name="services">The service registration collection.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseTaskLifetime <TLifetime>(this ICakeServices services)
            where TLifetime : IFrostingTaskLifetime
        {
            Guard.ArgumentNotNull(services, nameof(services));

            services.RegisterType <TLifetime>().As <IFrostingTaskLifetime>().Singleton();
            return(services);
        }
        /// <summary>
        /// Registers a specific tool for installation.
        /// </summary>
        /// <typeparam name="TPackageInstaller">The type of the package installer.</typeparam>
        /// <param name="services">The service registration collection.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UsePackageInstaller <TPackageInstaller>(this ICakeServices services)
            where TPackageInstaller : IPackageInstaller
        {
            Guard.ArgumentNotNull(services, nameof(services));

            services.RegisterType <TPackageInstaller>().As <IPackageInstaller>().Singleton();
            return(services);
        }
 public void Configure(ICakeServices services)
 {
     services.UseAssembly(typeof(Context).Assembly);
     services.UseAssembly(typeof(BitbucketCreateRepo).Assembly);
     services.UseContext <Context>();
     services.UseLifetime <Lifetime>();
     services.UseWorkingDirectory("..");
 }
Пример #9
0
 public void Configure(ICakeServices services)
 {
     services.UseAssembly(typeof(DotNetCoreBuild).Assembly);
     services.UseContext <DotNetCoreContext>();
     services.UseLifetime <DotNetCoreLifetime>();
     //services.UseContext<DynamicContext>();
     //services.UseLifetime<DynamicLifetime>();
     services.UseWorkingDirectory("../../");
 }
    public void Configure(ICakeServices services)
    {
        services.UseAssembly(typeof(DotNetCoreBuild).Assembly);
        services.UseContext <DotNetCoreContext>();
        services.UseLifetime <DotNetCoreLifetime>();
        services.UseWorkingDirectory("..");

        RegisterLifetimeActions();
    }
        /// <summary>
        /// Registers a specific tool for installation.
        /// </summary>
        /// <param name="services">The service registration collection.</param>
        /// <param name="uri">The tool URI.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseTool(this ICakeServices services, Uri uri)
        {
            Guard.ArgumentNotNull(services, nameof(services));

            var package = new PackageReference(uri.OriginalString);

            services.RegisterInstance(package).Singleton();
            return(services);
        }
        /// <summary>
        ///  Add or replace a setting in the configuration.
        /// </summary>
        /// <param name="services">The service registration collection.</param>
        /// <param name="key">The key of the setting to add or replace.</param>
        /// <param name="value">The value of the setting to add or replace.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseSetting(this ICakeServices services, string key, string value)
        {
            Guard.ArgumentNotNull(services, nameof(services));

            var info = new ConfigurationSetting(key, value);

            services.RegisterInstance(info).AsSelf().Singleton();
            return(services);
        }
        /// <summary>
        /// Registers the specified module type.
        /// </summary>
        /// <typeparam name="TModule">The type of the module.</typeparam>
        /// <param name="services">The service registration collection.</param>
        /// <returns>The same <see cref="ICakeServices"/> instance so that multiple calls can be chained.</returns>
        public static ICakeServices UseModule <TModule>(this ICakeServices services)
            where TModule : ICakeModule, new()
        {
            Guard.ArgumentNotNull(services, nameof(services));

            var module = new TModule();

            module.Register(services);
            return(services);
        }
Пример #14
0
            public void Should_Throw_If_Services_Reference_Is_Null()
            {
                // Given
                ICakeServices services = null;

                // When
                var result = Record.Exception(() => services.UseTool(new Uri("nuget:?package=Foo")));

                // Then
                AssertEx.IsArgumentNullException(result, "services");
            }
Пример #15
0
            public void Should_Throw_If_Services_Reference_Is_Null()
            {
                // Given
                ICakeServices services = null;

                // When
                var result = Record.Exception(() => services.UseContext <FrostingContext>());

                // Then
                AssertEx.IsArgumentNullException(result, "services");
            }
Пример #16
0
            public void Should_Throw_If_Services_Reference_Is_Null()
            {
                // Given
                ICakeServices services = null;

                // When
                var result = Record.Exception(() => services.UseTaskLifetime <DummyTaskLifetime>());

                // Then
                AssertEx.IsArgumentNullException(result, "services");
            }
Пример #17
0
            public void Should_Throw_If_Services_Reference_Is_Null()
            {
                // Given
                ICakeServices services = null;
                var           assembly = typeof(DateTime).GetTypeInfo().Assembly;

                // When
                var result = Record.Exception(() => services.UseAssembly(assembly));

                // Then
                AssertEx.IsArgumentNullException(result, "services");
            }
Пример #18
0
        public void Configure(ICakeServices services)
        {
            services.UseContext <Context>();
            services.UseLifetime <Lifetime>();
            services.UseTaskLifetime <TaskLifetime>();
            services.UseWorkingDirectory(".");
            services.UsePackageInstaller <NuGetPackageInstaller>();

            // Workaround, cannot use services.UseModule<NuGetModule>(), because there is no default constructor
            var nuGetModule = new NuGetModule(new CakeConfiguration(new Dictionary <string, string>()));

            nuGetModule.Register(services);
        }
Пример #19
0
    public void Configure(ICakeServices services)
    {
        services.UseContext <Context>();
        services.UseLifetime <Lifetime>();
        services.UseWorkingDirectory("..");

        // from https://github.com/cake-build/cake/discussions/2931
        var module = new NuGetModule(new CakeConfiguration(new Dictionary <string, string>()));

        module.Register(services);

        services.UseTool(new Uri("nuget:?package=GitVersion.CommandLine&version=5.0.1"));
        services.UseTool(new Uri("nuget:?package=Microsoft.TestPlatform&version=16.8.0"));
        services.UseTool(new Uri("nuget:?package=NUnitTestAdapter&version=2.3.0"));
        services.UseTool(new Uri("nuget:?package=NuGet.CommandLine&version=5.8.0"));
    }
Пример #20
0
 public void Configure(ICakeServices services)
 {
     services.RegisterType <DummyStartupSentinel>();
 }
Пример #21
0
 public void Configure(ICakeServices services)
 {
     services.UseContext <Settings>();
 }
 public void Configure(ICakeServices services)
 {
     services.UseContext <Context>();
     services.UseLifetime <Lifetime>();
 }
Пример #23
0
 public void Configure(ICakeServices services)
 {
     services.UseContext <Context>();
     services.UseLifetime <Lifetime>();
     services.UseWorkingDirectory("..");
 }