Exemplo n.º 1
0
        private void ReportInputsForItemType(ProjectPredictionReporter reporter, ProjectInstance projectInstance, string itemType, HashSet <string> reportedIncludes)
        {
            ICollection <ProjectItemInstance> items = projectInstance.GetItems(itemType);

            if (items.Count == 0)
            {
                return;
            }

            foreach (ProjectItemInstance item in items)
            {
                if (item.GetMetadataValue(ExcludedFromBuildMetadata).Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                string[] additionalIncludeDirectories = item.GetMetadataValue(AdditionalIncludeDirectoriesMetadata)
                                                        .Split(IncludePathsSeparator, StringSplitOptions.RemoveEmptyEntries);
                foreach (string directory in additionalIncludeDirectories)
                {
                    string trimmedDirectory = directory.Trim();
                    if (!string.IsNullOrEmpty(trimmedDirectory) && reportedIncludes.Add(trimmedDirectory))
                    {
                        reporter.ReportInputDirectory(trimmedDirectory);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public void PredictInputsAndOutputs(ProjectInstance project, ProjectPredictionReporter reporter)
        {
            // This is based on $(VCTargetsPath)\BuildCustomizations\masm.targets, if the before targets
            // property isn't set then the masm.targets haven't been imported, and no @(MASM) items will
            // be processed by the MASM targets.
            if (string.IsNullOrWhiteSpace(project.GetPropertyValue(MasmBeforeTargetsPropertyName)))
            {
                return;
            }

            ICollection <ProjectItemInstance> masmItems = project.GetItems(MasmItemName);

            if (masmItems.Count == 0)
            {
                return;
            }

            var reportedIncludes = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (ProjectItemInstance masmItem in masmItems)
            {
                if (IsExcludedFromBuild(masmItem))
                {
                    continue;
                }

                ReportInputs(reporter, masmItem, reportedIncludes);
                ReportOutputs(reporter, masmItem);
            }
        }
        /// <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);
            }
        }
            public void PredictInputsAndOutputs(ProjectGraphNode projectGraphNode, ProjectPredictionReporter predictionReporter)
            {
                foreach (ProjectGraphNode dependency in projectGraphNode.ProjectReferences)
                {
                    var dependencyDir = dependency.ProjectInstance.Directory;

                    foreach (string item in _inputFiles)
                    {
                        predictionReporter.ReportInputFile(Path.GetFullPath(Path.Combine(dependencyDir, item)));
                    }

                    foreach (string item in _inputDirectories)
                    {
                        predictionReporter.ReportInputDirectory(Path.GetFullPath(Path.Combine(dependencyDir, item)));
                    }

                    foreach (string item in _outputFiles)
                    {
                        predictionReporter.ReportOutputFile(Path.GetFullPath(Path.Combine(dependencyDir, item)));
                    }

                    foreach (string item in _outputDirectories)
                    {
                        predictionReporter.ReportOutputDirectory(Path.GetFullPath(Path.Combine(dependencyDir, item)));
                    }
                }
            }
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(ProjectGraphNode projectGraphNode, ProjectPredictionReporter predictionReporter)
        {
            var seenGraphNodes      = new HashSet <ProjectGraphNode>(projectGraphNode.ProjectReferences);
            var graphNodesToProcess = new Queue <ProjectGraphNode>(projectGraphNode.ProjectReferences);

            while (graphNodesToProcess.Count > 0)
            {
                ProjectGraphNode currentNode = graphNodesToProcess.Dequeue();

                // Predict the project file itself and all its imports.
                predictionReporter.ReportInputFile(currentNode.ProjectInstance.FullPath);
                foreach (string import in currentNode.ProjectInstance.ImportPaths)
                {
                    predictionReporter.ReportInputFile(import);
                }

                // Recurse transitively
                foreach (ProjectGraphNode projectReference in currentNode.ProjectReferences)
                {
                    if (seenGraphNodes.Add(projectReference))
                    {
                        graphNodesToProcess.Enqueue(projectReference);
                    }
                }
            }
        }
        private static void ReportCopyToPublishDirectoryItems(
            ProjectInstance projectInstance,
            string itemName,
            string publishDir,
            ProjectPredictionReporter predictionReporter)
        {
            foreach (ProjectItemInstance item in projectInstance.GetItems(itemName))
            {
                var copyToPublishDirectoryValue = item.GetMetadataValue(CopyToPublishDirectoryMetadataName);
                if (copyToPublishDirectoryValue.Equals("Always", StringComparison.OrdinalIgnoreCase) ||
                    copyToPublishDirectoryValue.Equals("PreserveNewest", StringComparison.OrdinalIgnoreCase))
                {
                    // The item will be relative to the project instance passed in, not the current project instance, so make the path absolute.
                    predictionReporter.ReportInputFile(Path.Combine(projectInstance.Directory, item.EvaluatedInclude));

                    if (!string.IsNullOrEmpty(publishDir))
                    {
                        string targetPath = item.GetTargetPath();
                        if (!string.IsNullOrEmpty(targetPath))
                        {
                            predictionReporter.ReportOutputFile(Path.Combine(publishDir, targetPath));
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(ProjectGraphNode projectGraphNode, ProjectPredictionReporter predictionReporter)
        {
            ProjectInstance projectInstance = projectGraphNode.ProjectInstance;

            // The GetCopyToOutputDirectoryItems target gets called on all dependencies, unless UseCommonOutputDirectory is set to true.
            var useCommonOutputDirectory = projectInstance.GetPropertyValue(UseCommonOutputDirectoryPropertyName);

            if (!useCommonOutputDirectory.Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                string outDir = projectInstance.GetPropertyValue(OutDirPropertyName);

                // Note that GetCopyToOutputDirectoryItems effectively only is able to go one project reference deep despite being recursive as
                // it uses @(_MSBuildProjectReferenceExistent) to recurse, which is not set in the recursive calls.
                // See: https://github.com/microsoft/msbuild/blob/master/src/Tasks/Microsoft.Common.CurrentVersion.targets
                foreach (ProjectGraphNode dependency in projectGraphNode.ProjectReferences)
                {
                    // Process each item type considered in GetCopyToOutputDirectoryItems. Yes, Compile is considered.
                    ReportCopyToOutputDirectoryItemsAsInputs(dependency.ProjectInstance, ContentItemsPredictor.ContentItemName, outDir, predictionReporter);
                    ReportCopyToOutputDirectoryItemsAsInputs(dependency.ProjectInstance, EmbeddedResourceItemsPredictor.EmbeddedResourceItemName, outDir, predictionReporter);
                    ReportCopyToOutputDirectoryItemsAsInputs(dependency.ProjectInstance, CompileItemsPredictor.CompileItemName, outDir, predictionReporter);
                    ReportCopyToOutputDirectoryItemsAsInputs(dependency.ProjectInstance, NoneItemsPredictor.NoneItemName, outDir, predictionReporter);

                    // Process each item type considered in GetCopyToOutputDirectoryXamlAppDefs
                    ReportCopyToOutputDirectoryItemsAsInputs(dependency.ProjectInstance, XamlAppDefPredictor.XamlAppDefItemName, outDir, predictionReporter);
                }
            }
        }
Exemplo n.º 8
0
        private void ReportInputAndRelatedFiles(
            string referencePath,
            string projectDirectory,
            List <string> relatedFileExtensions,
            ProjectPredictionReporter predictionReporter)
        {
            var referenceFullPath = Path.GetFullPath(Path.Combine(projectDirectory, referencePath));

            predictionReporter.ReportInputFile(referenceFullPath);

            // If the reference doesn't exist, it might be generated by the build.
            // In that case, we can't know for sure whether there will be related
            // files or not, so don't bother trying in that case.
            if (!File.Exists(referenceFullPath))
            {
                return;
            }

            foreach (var ext in relatedFileExtensions)
            {
                var relatedFile = Path.ChangeExtension(referenceFullPath, ext);
                if (File.Exists(relatedFile))
                {
                    predictionReporter.ReportInputFile(relatedFile);
                }
            }
        }
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            string ruleSetPath = projectInstance.GetPropertyValue(CodeAnalysisRuleSetPropertyName);

            if (string.IsNullOrWhiteSpace(ruleSetPath))
            {
                // Bail out fast if no rulset is configured.
                return;
            }

            string        ruleSetDirectoriesStr = projectInstance.GetPropertyValue(CodeAnalysisRuleSetDirectoriesPropertyName);
            List <string> ruleSetDirectories    = string.IsNullOrWhiteSpace(ruleSetDirectoriesStr)
                ? _emptyList
                : ruleSetDirectoriesStr.SplitStringList();

            HashSet <string> inputs = ParseRuleset(
                ruleSetPath,
                ruleSetDirectories,
                projectInstance.Directory,
                visitedRuleSets: null,
                isInCycle: false);

            foreach (string input in inputs)
            {
                predictionReporter.ReportInputFile(input);
            }
        }
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            // This predictor only applies to sqlproj files
            if (!projectInstance.FullPath.EndsWith(".sqlproj", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            foreach (ProjectItemInstance item in projectInstance.GetItems(BuildItemName))
            {
                predictionReporter.ReportInputFile(item.EvaluatedInclude);
            }

            foreach (ProjectItemInstance item in projectInstance.GetItems(PostDeployItemName))
            {
                predictionReporter.ReportInputFile(item.EvaluatedInclude);
            }

            foreach (ProjectItemInstance item in projectInstance.GetItems(PreDeployItemName))
            {
                predictionReporter.ReportInputFile(item.EvaluatedInclude);
            }
        }
 /// <inheritdoc/>
 public void PredictInputsAndOutputs(ProjectGraphNode projectGraphNode, ProjectPredictionReporter predictionReporter)
 {
     if (IsPublishing(projectGraphNode.ProjectInstance))
     {
         string publishDir = projectGraphNode.ProjectInstance.GetPropertyValue(PublishDirPropertyName);
         PredictInputsAndOutputs(projectGraphNode, publishDir, predictionReporter);
     }
 }
Exemplo n.º 12
0
 /// <inheritdoc/>
 public void PredictInputsAndOutputs(
     ProjectInstance projectInstance,
     ProjectPredictionReporter predictionReporter)
 {
     foreach (ProjectItemInstance item in projectInstance.GetItems(PageItemName))
     {
         predictionReporter.ReportInputFile(item.EvaluatedInclude);
     }
 }
Exemplo n.º 13
0
 /// <inheritdoc/>
 public void PredictInputsAndOutputs(
     ProjectInstance projectInstance,
     ProjectPredictionReporter predictionReporter)
 {
     predictionReporter.ReportInputFile(projectInstance.FullPath);
     foreach (string importPath in projectInstance.ImportPaths)
     {
         predictionReporter.ReportInputFile(importPath);
     }
 }
Exemplo n.º 14
0
        public static ProjectPredictions GetProjectPredictions(this IProjectPredictor predictor, ProjectInstance projectInstance)
        {
            var projectPredictionCollector = new DefaultProjectPredictionCollector();
            var predictionReporter         = new ProjectPredictionReporter(
                projectPredictionCollector,
                projectInstance,
                predictor.GetType().Name);

            predictor.PredictInputsAndOutputs(projectInstance, predictionReporter);
            return(projectPredictionCollector.Predictions);
        }
Exemplo n.º 15
0
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            var assemblyOriginatorKeyFile = projectInstance.GetPropertyValue(ApplicationIconPropertyName);

            if (!string.IsNullOrEmpty(assemblyOriginatorKeyFile))
            {
                predictionReporter.ReportInputFile(assemblyOriginatorKeyFile);
            }
        }
Exemplo n.º 16
0
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            string intermediateOutputPath = projectInstance.GetPropertyValue(IntermediateOutputPathMacro);

            if (!string.IsNullOrWhiteSpace(intermediateOutputPath))
            {
                predictionReporter.ReportOutputDirectory(intermediateOutputPath);
            }
        }
 private static void ReportCopyToPublishDirectoryItems(
     ProjectInstance projectInstance,
     string publishDir,
     ProjectPredictionReporter predictionReporter)
 {
     // Process each item type considered in GetCopyToPublishDirectoryItems. Yes, Compile is considered.
     ReportCopyToPublishDirectoryItems(projectInstance, ContentItemsPredictor.ContentItemName, publishDir, predictionReporter);
     ReportCopyToPublishDirectoryItems(projectInstance, EmbeddedResourceItemsPredictor.EmbeddedResourceItemName, publishDir, predictionReporter);
     ReportCopyToPublishDirectoryItems(projectInstance, CompileItemsPredictor.CompileItemName, publishDir, predictionReporter);
     ReportCopyToPublishDirectoryItems(projectInstance, NoneItemsPredictor.NoneItemName, publishDir, predictionReporter);
 }
Exemplo n.º 18
0
        public static ProjectPredictions GetProjectPredictions(this IProjectGraphPredictor predictor, string projectFile)
        {
            var graph                      = new ProjectGraph(projectFile, _globalProperties, new ProjectCollection());
            var entryPointNode             = graph.EntryPointNodes.Single();
            var projectPredictionCollector = new DefaultProjectPredictionCollector();
            var predictionReporter         = new ProjectPredictionReporter(
                projectPredictionCollector,
                entryPointNode.ProjectInstance,
                predictor.GetType().Name);

            predictor.PredictInputsAndOutputs(entryPointNode, predictionReporter);
            return(projectPredictionCollector.Predictions);
        }
        private void ReportInputsForItemType(ProjectPredictionReporter reporter, ProjectInstance projectInstance, string itemType)
        {
            ICollection <ProjectItemInstance> items = projectInstance.GetItems(itemType);

            if (items.Count == 0)
            {
                return;
            }

            foreach (ProjectItemInstance item in items)
            {
                reporter.ReportInputFile(item.EvaluatedInclude);
            }
        }
Exemplo n.º 20
0
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            List <string> relatedFileExtensions = projectInstance.GetPropertyValue(AllowedReferenceRelatedFileExtensionsPropertyName).SplitStringList();

            foreach (ProjectItemInstance item in projectInstance.GetItems(ReferenceItemName))
            {
                if (TryGetReferenceItemFilePath(projectInstance, item, out string filePath))
                {
                    ReportInputAndRelatedFiles(filePath, projectInstance.Directory, relatedFileExtensions, predictionReporter);
                }
            }
        }
        internal static void PredictInputsAndOutputs(
            ProjectGraphNode projectGraphNode,
            string publishDir,
            ProjectPredictionReporter predictionReporter)
        {
            ReportCopyToPublishDirectoryItems(projectGraphNode.ProjectInstance, publishDir, predictionReporter);

            // Note that GetCopyToPublishDirectoryItems effectively only is able to go one project reference deep despite appearing recursive for the same reasons as GetCopyToOutputDirectoryItems.
            // See: https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
            foreach (ProjectGraphNode dependency in projectGraphNode.ProjectReferences)
            {
                ReportCopyToPublishDirectoryItems(dependency.ProjectInstance, publishDir, predictionReporter);
            }
        }
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(ProjectInstance projectInstance, ProjectPredictionReporter predictionReporter)
        {
            // This predictor only applies to projects using the Microsoft.Build.Artifacts Sdk.
            var usingMicrosoftArtifactsSdk = projectInstance.GetPropertyValue(UsingMicrosoftArtifactsSdkPropertyName);

            if (!usingMicrosoftArtifactsSdk.Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // The Sdk allows both Artifacts and Robocopy items
            ProcessItems(projectInstance.GetItems(ArtifactsItemName), predictionReporter);
            ProcessItems(projectInstance.GetItems(RobocopyItemName), predictionReporter);
        }
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(ProjectGraphNode projectGraphNode, ProjectPredictionReporter predictionReporter)
        {
            ProjectInstance projectInstance = projectGraphNode.ProjectInstance;

            // This predictor only applies to sfproj files
            if (!projectInstance.FullPath.EndsWith(".sfproj", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            if (projectGraphNode.ProjectReferences.Count == 0)
            {
                return;
            }

            string servicePackageRootFolder = projectInstance.GetPropertyValue(ServicePackageRootFolderPropertyName);

            if (string.IsNullOrEmpty(servicePackageRootFolder))
            {
                return;
            }

            foreach (ProjectGraphNode projectReference in projectGraphNode.ProjectReferences)
            {
                // This emulates the behavior of the GetPackageRootFiles task.
                // We do not emulate the behavior of the FilterPackageFiles task as it requires parsing the service manifest
                // and the extra cost and complexity does not outweigh the slight overprediction.
                // For the same reason we are not doing output prediction.
                string projectFolder       = Path.GetFullPath(Path.GetDirectoryName(projectReference.ProjectInstance.FullPath));
                string fullPackageRootPath = Path.Combine(projectFolder, servicePackageRootFolder);
                if (fullPackageRootPath[fullPackageRootPath.Length - 1] != Path.DirectorySeparatorChar)
                {
                    fullPackageRootPath += Path.DirectorySeparatorChar;
                }

                // Add files from none and content items under the package root path.
                // This is basically the same as the directory enumeration below, but there are some slight differences, so emulating
                // the odd behavior of GetPackageRootFiles is preferable to potentially being wrong.
                AddPackageRootFilesFromItems(projectReference.ProjectInstance.GetItems(NoneItemsPredictor.NoneItemName), projectFolder, fullPackageRootPath, predictionReporter);
                AddPackageRootFilesFromItems(projectReference.ProjectInstance.GetItems(ContentItemsPredictor.ContentItemName), projectFolder, fullPackageRootPath, predictionReporter);

                // Add files under the package root path.
                string[] packageRootFilesInFileSystem = Directory.GetFiles(fullPackageRootPath, "*", SearchOption.AllDirectories);
                foreach (string packageRootFileInFileSystem in packageRootFilesInFileSystem)
                {
                    predictionReporter.ReportInputFile(packageRootFileInFileSystem);
                }
            }
        }
Exemplo n.º 24
0
        /// <inheritdoc />
        public void PredictInputsAndOutputs(ProjectInstance projectInstance, ProjectPredictionReporter reporter)
        {
            // This predictor only applies to vcxproj files
            if (!projectInstance.FullPath.EndsWith(".vcxproj", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // ModuleDefinitionFile are commonly added via an ItemDefinitionGroup, so use a HashSet to dedupe the repeats.
            var reportedInputs = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            ReportInputsForItemType(reporter, projectInstance, LinkItemName, reportedInputs);
            ReportInputsForItemType(reporter, projectInstance, LibItemName, reportedInputs);
            ReportInputsForItemType(reporter, projectInstance, ImpLibItemName, reportedInputs);
        }
Exemplo n.º 25
0
 /// <inheritdoc/>
 public void PredictInputsAndOutputs(
     ProjectInstance projectInstance,
     ProjectPredictionReporter predictionReporter)
 {
     foreach (ProjectItemInstance item in projectInstance.GetItems(ClIncludeItemName))
     {
         // ClInclude items aren't directly used by the build process, but they're usually read during compilation of a cpp file via #include
         // Because of this, they're merely a hint and might not actually be read, so check for file existence.
         string clIncludeFullPath = Path.Combine(projectInstance.Directory, item.EvaluatedInclude);
         if (File.Exists(clIncludeFullPath))
         {
             predictionReporter.ReportInputFile(clIncludeFullPath);
         }
     }
 }
Exemplo n.º 26
0
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            List <string> relatedFileExtensions = projectInstance.GetPropertyValue(AllowedReferenceRelatedFileExtensionsPropertyName).SplitStringList();

            foreach (ProjectItemInstance item in projectInstance.GetItems(ReferenceItemName))
            {
                // <HintPath> metadata is treated as the truth if it exists.
                // Example: <Reference Include="SomeAssembly">
                //            <HintPath>..\packages\SomePackage.1.0.0.0\lib\net45\SomeAssembly.dll</HintPath>
                //          </Reference>
                string hintPath = item.GetMetadataValue(HintPathMetadata);
                if (!string.IsNullOrEmpty(hintPath))
                {
                    ReportInputAndRelatedFiles(hintPath, projectInstance.Directory, relatedFileExtensions, predictionReporter);
                    continue;
                }
                else
                {
                    // If there is no hint path then if the reference is valid then the EvaluatedInclude is either a path to a file
                    // or the name of a dll from the GAC or platform.
                    string identity = item.EvaluatedInclude;

                    // Since we don't know whether it's even a file path, check that it's at least a valid path before trying to use it like one.
                    if (identity.IndexOfAny(_invalidPathCharacters) != -1)
                    {
                        continue;
                    }

                    // If it's from the GAC or platform, it won't have directory separators.
                    // Example: <Reference Include="System.Data" />
                    if (identity.IndexOf(Path.DirectorySeparatorChar, StringComparison.Ordinal) == -1)
                    {
                        // Edge-case if the reference is adjacent to the project so might not have directory separators. Check file existence in that case.
                        // Example: <Reference Include="CheckedInReference.dll" />
                        if (!File.Exists(Path.Combine(projectInstance.Directory, identity)))
                        {
                            continue;
                        }
                    }

                    // The value seems like it could be a file path since it's a valid path and has directory separators. Note that we can't
                    // actually check for file existence here since it might be a reference to an assembly produced by another project in the repository.
                    ReportInputAndRelatedFiles(identity, projectInstance.Directory, relatedFileExtensions, predictionReporter);
                }
            }
        }
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            // The symbols file as output directly from the compiler.
            foreach (ProjectItemInstance item in projectInstance.GetItems(DebugSymbolsIntermediatePathItemName))
            {
                predictionReporter.ReportOutputFile(item.EvaluatedInclude);
            }

            // CopyFilesToOutputDirectory copies @(_DebugSymbolsIntermediatePath) items to the output directory using a different item group.
            foreach (ProjectItemInstance item in projectInstance.GetItems(DebugSymbolsOutputPathItemName))
            {
                predictionReporter.ReportOutputFile(item.EvaluatedInclude);
            }
        }
Exemplo n.º 28
0
        /// <inheritdoc />
        public void PredictInputsAndOutputs(ProjectInstance projectInstance, ProjectPredictionReporter reporter)
        {
            // This predictor only applies to vcxproj files
            if (!projectInstance.FullPath.EndsWith(".vcxproj", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // AdditionalIncludeDirectories are commonly added via an ItemDefinitionGroup, so use a HashSet to dedupe the repeats.
            var reportedIncludes = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            ReportInputsForItemType(reporter, projectInstance, ClCompileItemName, reportedIncludes);
            ReportInputsForItemType(reporter, projectInstance, FxCompileItemName, reportedIncludes);
            ReportInputsForItemType(reporter, projectInstance, MidlItemName, reportedIncludes);
            ReportInputsForItemType(reporter, projectInstance, ResourceCompileItemName, reportedIncludes);
        }
        /// <inheritdoc/>
        public void PredictInputsAndOutputs(
            ProjectInstance projectInstance,
            ProjectPredictionReporter predictionReporter)
        {
            var availableItemNames = new HashSet <string>(
                projectInstance.GetItems(AvailableItemName).Select(item => item.EvaluatedInclude),
                StringComparer.OrdinalIgnoreCase);

            foreach (string availableItemName in availableItemNames)
            {
                foreach (ProjectItemInstance item in projectInstance.GetItems(availableItemName))
                {
                    predictionReporter.ReportInputFile(item.EvaluatedInclude);
                }
            }
        }
Exemplo n.º 30
0
        private void ReportInputs(ProjectPredictionReporter reporter, ProjectItemInstance masmItem, HashSet <string> reportedIncludes)
        {
            reporter.ReportInputFile(masmItem.EvaluatedInclude);

            string[] includePaths = masmItem.GetMetadataValue(IncludePathsMetadata)
                                    .Split(IncludePathsSeparator, StringSplitOptions.RemoveEmptyEntries);

            // Avoid reporting paths that we've already reported for this project.
            foreach (string includePath in includePaths)
            {
                string trimmedPath = includePath.Trim();
                if (!string.IsNullOrEmpty(trimmedPath) && reportedIncludes.Add(trimmedPath))
                {
                    reporter.ReportInputDirectory(trimmedPath);
                }
            }
        }