Example #1
0
        private bool CheckGlobalConditions(BuildAction buildAction, BuildUpToDateCheckLogger logger, State state)
        {
            if (buildAction != BuildAction.Build)
            {
                return(false);
            }

            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                return(Fail(logger, "CriticalTasks", "Critical build tasks are running, not up to date."));
            }

            if (state.LastVersionSeen == null || _configuredProject.ProjectVersion.CompareTo(state.LastVersionSeen) > 0)
            {
                return(Fail(logger, "ProjectInfoOutOfDate", "Project information is older than current project version, not up to date."));
            }

            if (state.IsDisabled)
            {
                return(Fail(logger, "Disabled", "The 'DisableFastUpToDateCheck' property is true, not up to date."));
            }

            string copyAlwaysItemPath = state.ItemsByItemType.SelectMany(kvp => kvp.Value).FirstOrDefault(item => item.copyType == CopyToOutputDirectoryType.CopyAlways).path;

            if (copyAlwaysItemPath != null)
            {
                return(Fail(logger, "CopyAlwaysItemExists", "Item '{0}' has CopyToOutputDirectory set to 'Always', not up to date.", _configuredProject.UnconfiguredProject.MakeRooted(copyAlwaysItemPath)));
            }

            return(true);
        }
Example #2
0
        private bool CheckGlobalConditions(Log log, DateTime lastCheckedAtUtc, bool validateFirstRun, UpToDateCheckImplicitConfiguredInput state)
        {
            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                return(log.Fail("CriticalTasks", nameof(Resources.FUTD_CriticalBuildTasksRunning)));
            }

            if (state.IsDisabled)
            {
                return(log.Fail("Disabled", nameof(Resources.FUTD_DisableFastUpToDateCheckTrue)));
            }

            if (validateFirstRun && !state.WasStateRestored && lastCheckedAtUtc == DateTime.MinValue)
            {
                // We had no persisted state, and this is the first run. We cannot know if the project is up-to-date
                // or not, so schedule a build.
                return(log.Fail("FirstRun", nameof(Resources.FUTD_FirstRun)));
            }

            foreach ((_, ImmutableArray <UpToDateCheckInputItem> items) in state.InputSourceItemsByItemType)
            {
                foreach (UpToDateCheckInputItem item in items)
                {
                    if (item.CopyType == CopyType.CopyAlways)
                    {
                        return(log.Fail("CopyAlwaysItemExists", nameof(Resources.FUTD_CopyAlwaysItemExists_1), _configuredProject.UnconfiguredProject.MakeRooted(item.Path)));
                    }
                }
            }

            return(true);
        }
Example #3
0
        private bool CheckGlobalConditions(Log log, DateTime lastCheckedAtUtc, UpToDateCheckImplicitConfiguredInput state)
        {
            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                return(log.Fail("CriticalTasks", "Critical build tasks are running, not up to date."));
            }

            if (state.LastVersionSeen == null || _configuredProject.ProjectVersion.CompareTo(state.LastVersionSeen) > 0)
            {
                return(log.Fail("ProjectInfoOutOfDate", "Project information is older than current project version, not up to date."));
            }

            if (state.IsDisabled)
            {
                return(log.Fail("Disabled", "The 'DisableFastUpToDateCheck' property is true, not up to date."));
            }

            if (lastCheckedAtUtc == DateTime.MinValue)
            {
                return(log.Fail("FirstRun", "The up-to-date check has not yet run for this project. Not up-to-date."));
            }

            string copyAlwaysItemPath = state.ItemsByItemType.SelectMany(kvp => kvp.Value).FirstOrDefault(item => item.CopyType == CopyType.CopyAlways).Path;

            if (copyAlwaysItemPath != null)
            {
                return(log.Fail("CopyAlwaysItemExists", "Item '{0}' has CopyToOutputDirectory set to 'Always', not up to date.", _configuredProject.UnconfiguredProject.MakeRooted(copyAlwaysItemPath)));
            }

            return(true);
        }
Example #4
0
        private bool CheckGlobalConditions(Log log, DateTime lastCheckedAtUtc, UpToDateCheckImplicitConfiguredInput state)
        {
            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                return(log.Fail("CriticalTasks", "Critical build tasks are running, not up to date."));
            }

            if (state.LastVersionSeen == null || _configuredProject.ProjectVersion.CompareTo(state.LastVersionSeen) > 0)
            {
                return(log.Fail("ProjectInfoOutOfDate", "Project information is older than current project version, not up to date."));
            }

            if (state.IsDisabled)
            {
                return(log.Fail("Disabled", "The 'DisableFastUpToDateCheck' property is true, not up to date."));
            }

            if (lastCheckedAtUtc == DateTime.MinValue)
            {
                return(log.Fail("FirstRun", "The up-to-date check has not yet run for this project. Not up-to-date."));
            }

            foreach ((_, ImmutableArray <(string Path, string?Link, CopyType CopyType)> items) in state.ItemsByItemType)
            {
                foreach ((string path, _, CopyType copyType) in items)
                {
                    if (copyType == CopyType.CopyAlways)
                    {
                        return(log.Fail("CopyAlwaysItemExists", "Item '{0}' has CopyToOutputDirectory set to 'Always', not up to date.", _configuredProject.UnconfiguredProject.MakeRooted(path)));
                    }
                }
            }

            return(true);
        }
        private bool CheckGlobalConditions(Log log, DateTime lastCheckedAtUtc, UpToDateCheckImplicitConfiguredInput state)
        {
            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                return(log.Fail("CriticalTasks", "Critical build tasks are running, not up to date."));
            }

            if (state.IsDisabled)
            {
                return(log.Fail("Disabled", "The 'DisableFastUpToDateCheck' property is true, not up to date."));
            }

            if (!state.WasStateRestored && lastCheckedAtUtc == DateTime.MinValue)
            {
                // We had no persisted state, and this is the first run. We cannot know if the project is up-to-date
                // or not, so schedule a build.
                return(log.Fail("FirstRun", "The up-to-date check has not yet run for this project. Not up-to-date."));
            }

            foreach ((_, ImmutableArray <(string Path, string?TargetPath, CopyType CopyType)> items) in state.ItemsByItemType)
            {
                foreach ((string path, _, CopyType copyType) in items)
                {
                    if (copyType == CopyType.CopyAlways)
                    {
                        return(log.Fail("CopyAlwaysItemExists", "Item '{0}' has CopyToOutputDirectory set to 'Always', not up to date.", _configuredProject.UnconfiguredProject.MakeRooted(path)));
                    }
                }
            }

            return(true);
        }
        private bool CheckGlobalConditions(Log log, DateTime lastSuccessfulBuildStartTimeUtc, bool validateFirstRun, UpToDateCheckImplicitConfiguredInput state)
        {
            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                return(log.Fail("CriticalTasks", nameof(Resources.FUTD_CriticalBuildTasksRunning)));
            }

            if (state.IsDisabled)
            {
                return(log.Fail("Disabled", nameof(Resources.FUTD_DisableFastUpToDateCheckTrue)));
            }

            if (validateFirstRun && !state.WasStateRestored && lastSuccessfulBuildStartTimeUtc == DateTime.MinValue)
            {
                // We had no persisted state, and this is the first run. We cannot know if the project is up-to-date
                // or not, so schedule a build.
                return(log.Fail("FirstRun", nameof(Resources.FUTD_FirstRun)));
            }

            if (state.IsCopyAlwaysOptimizationDisabled)
            {
                // By default, we optimize CopyAlways to only copy if the time stamps or file sizes differ.
                // If we got here, then the user has opted out of that optimisation, and we must fail if any CopyAlways items exist.

                foreach ((string itemType, ImmutableArray <UpToDateCheckInputItem> items) in state.InputSourceItemsByItemType)
                {
                    foreach (UpToDateCheckInputItem item in items)
                    {
                        if (item.CopyType == CopyType.Always)
                        {
                            return(log.Fail("CopyAlwaysItemExists", nameof(Resources.FUTD_CopyAlwaysItemExists_2), itemType, _configuredProject.UnconfiguredProject.MakeRooted(item.Path)));
                        }
                    }
                }
            }

            return(true);
        }
        private bool CheckGlobalConditions(BuildAction buildAction, Logger logger)
        {
            if (buildAction != BuildAction.Build)
            {
                return(false);
            }

            var itemsChangedSinceLastCheck = _itemsChangedSinceLastCheck;

            _itemsChangedSinceLastCheck = false;

            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                logger.Info("Critical build tasks are running, skipping check.");
                return(false);
            }

            if (_lastVersionSeen == null || _configuredProject.ProjectVersion.CompareTo(_lastVersionSeen) > 0)
            {
                logger.Info("Project information is older than current project version, skipping check.");
                return(false);
            }

            if (itemsChangedSinceLastCheck)
            {
                logger.Info("The list of source items has changed since the last build.");
                return(false);
            }

            if (_isDisabled)
            {
                logger.Info("The 'DisableFastUpToDateCheckProperty' property is true, skipping check.");
                return(false);
            }

            return(true);
        }
Example #8
0
        private bool CheckGlobalConditions(Log log, DateTime lastSuccessfulBuildStartTimeUtc, bool validateFirstRun, UpToDateCheckImplicitConfiguredInput state)
        {
            if (!_tasksService.IsTaskQueueEmpty(ProjectCriticalOperation.Build))
            {
                return(log.Fail("CriticalTasks", nameof(Resources.FUTD_CriticalBuildTasksRunning)));
            }

            if (state.IsDisabled)
            {
                return(log.Fail("Disabled", nameof(Resources.FUTD_DisableFastUpToDateCheckTrue)));
            }

            if (validateFirstRun && !state.WasStateRestored && lastSuccessfulBuildStartTimeUtc == DateTime.MinValue)
            {
                // We had no persisted state, and this is the first run. We cannot know if the project is up-to-date
                // or not, so schedule a build.
                return(log.Fail("FirstRun", nameof(Resources.FUTD_FirstRun)));
            }

            if (lastSuccessfulBuildStartTimeUtc < state.LastItemsChangedAtUtc)
            {
                log.Fail("ProjectItemsChangedSinceLastSuccessfulBuildStart", nameof(Resources.FUTD_SetOfItemsChangedMoreRecentlyThanOutput_2), state.LastItemsChangedAtUtc, lastSuccessfulBuildStartTimeUtc);

                if (log.Level >= LogLevel.Info)
                {
                    log.Indent++;

                    if (state.LastItemChanges.Length == 0)
                    {
                        log.Info(nameof(Resources.FUTD_SetOfChangedItemsIsEmpty));
                    }
                    else
                    {
                        foreach ((bool isAdd, string itemType, UpToDateCheckInputItem item) in state.LastItemChanges.OrderBy(change => change.ItemType).ThenBy(change => change.Item.Path))
                        {
                            log.Info(isAdd ? nameof(Resources.FUTD_ChangedItemsAddition_4) : nameof(Resources.FUTD_ChangedItemsRemoval_4), itemType, item.Path, item.CopyType, item.TargetPath ?? "");
                        }
                    }

                    log.Indent--;
                }

                return(false);
            }

            if (state.IsCopyAlwaysOptimizationDisabled)
            {
                // By default, we optimize CopyAlways to only copy if the time stamps or file sizes differ.
                // If we got here, then the user has opted out of that optimisation, and we must fail if any CopyAlways items exist.

                foreach ((string itemType, ImmutableArray <UpToDateCheckInputItem> items) in state.InputSourceItemsByItemType)
                {
                    foreach (UpToDateCheckInputItem item in items)
                    {
                        if (item.CopyType == CopyType.Always)
                        {
                            return(log.Fail("CopyAlwaysItemExists", nameof(Resources.FUTD_CopyAlwaysItemExists_2), itemType, _configuredProject.UnconfiguredProject.MakeRooted(item.Path)));
                        }
                    }
                }
            }

            return(true);
        }