public void Should_Add_Dependee_To_Task()
            {
                // Given
                var task    = new CakeTask("task");
                var builder = new CakeTaskBuilder(task);

                // When
                builder.IsDependeeOf("other");

                // Then
                Assert.Single(task.Dependees);
                Assert.Equal("other", task.Dependees[0].Name);
            }
예제 #2
0
            public void Should_Add_Dependee_To_Task()
            {
                // Given
                var task    = new ActionTask("task");
                var builder = new CakeTaskBuilder <ActionTask>(task);

                // When
                builder.IsDependeeOf("other");

                // Then
                Assert.Equal(1, task.Dependees.Count);
                Assert.Equal("other", task.Dependees[0].Name);
            }
        /// <summary>
        /// Configures the dependency, criteria and error handling for a dotnet-lib recipe task
        /// </summary>
        /// <param name="builder">Cake task builder</param>
        /// <param name="lib"><see cref="DotNetLib"/> recipe configuration</param>
        /// <param name="dependentOn">Dependent task name</param>
        /// <param name="dependee">Dependee task name</param>
        /// <returns></returns>
        public static CakeTaskBuilder ConfigTaskFor(
            this CakeTaskBuilder builder,
            DotNetLib lib,
            string dependentOn,
            string dependee = null)
        {
            // Bump dependent task forward based on recipe config
            if (dependentOn == lib.Tasks.Names.Commit && !lib.UseCommitTask)
            {
                dependentOn = lib.Tasks.Names.Package;
            }

            if (dependentOn == lib.Tasks.Names.PostBuild && !lib.UsePostBuildTask)
            {
                dependentOn = lib.Tasks.Names.Build;
            }

            if (dependentOn == lib.Tasks.Names.PreBuild && !lib.UsePreBuildTask)
            {
                dependentOn = lib.Tasks.Names.Clean;
            }

            if (dependentOn == lib.Tasks.Names.AssemblyInfo && !lib.UpdateAssemblyInfo)
            {
                dependentOn = lib.Tasks.Names.ReleaseNotes;
            }

            if (dependentOn == lib.Tasks.Names.ReleaseNotes && !lib.PrepareReleaseNotes)
            {
                dependentOn = lib.Tasks.Names.Version;
            }

            builder
            .IsDependentOn(dependentOn)
            .WithCriteria(() => !lib.SkipRemainingTasks && !lib.Errored)
            .OnError(ex => lib.SetError(builder, ex));

            // Bump dependee back based on lib config
            if (!string.IsNullOrEmpty(dependee))
            {
                if (dependee == lib.Tasks.Names.ReleaseNotes && !lib.PrepareReleaseNotes)
                {
                    dependee = lib.Tasks.Names.AssemblyInfo;
                }

                if (dependee == lib.Tasks.Names.AssemblyInfo && !lib.UpdateAssemblyInfo)
                {
                    dependee = lib.Tasks.Names.Clean;
                }

                if (dependee == lib.Tasks.Names.PreBuild && !lib.UsePreBuildTask)
                {
                    dependee = lib.Tasks.Names.Build;
                }

                if (dependee == lib.Tasks.Names.PostBuild && !lib.UsePostBuildTask)
                {
                    dependee = lib.Tasks.Names.Test;
                }

                if (dependee == lib.Tasks.Names.Commit && !lib.UseCommitTask)
                {
                    dependee = lib.Tasks.Names.Push;
                }

                builder.IsDependeeOf(dependee);
            }

            return(builder);
        }