コード例 #1
0
        /// <inheritdoc />
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            // Determine the active Targets in this Project.
            var activeTargets = new Dictionary <string, ProjectTargetInstance>(StringComparer.OrdinalIgnoreCase);

            // Start with the default targets, initial targets and all of their parent targets, the closure of its dependencies.
            foreach (string target in projectInstance.DefaultTargets)
            {
                projectInstance.AddToActiveTargets(target, activeTargets);
            }

            foreach (string target in projectInstance.InitialTargets)
            {
                projectInstance.AddToActiveTargets(target, activeTargets);
            }

            // Aside from InitialTargets and DefaultTargets, for completeness of inputs/outputs detection,
            // include custom targets defined directly in this Project.
            // Note that this misses targets defined in any custom targets files.
            foreach (ProjectTargetInstance target in projectInstance.Targets.Values
                     .Where(t => string.Equals(t.Location.File, projectInstance.ProjectFileLocation.File, PathComparer.Comparison)))
            {
                projectInstance.AddToActiveTargets(target.Name, activeTargets);
            }

            projectInstance.AddBeforeAndAfterTargets(activeTargets);

            // Then parse copy tasks for these targets.
            foreach (KeyValuePair <string, ProjectTargetInstance> target in activeTargets)
            {
                ParseCopyTask(target.Value, projectInstance, predictionReporter);
            }
        }