private static void ProcessCsProjFileContents(HashSet <string> csProjFilesProcessed, string[] csProjFilePaths, string csProjFilePath)
        {
            var csProjFileDirectoryPath = Path.GetDirectoryName(csProjFilePath);
            var csProjFileContents      = File.ReadAllText(csProjFilePath);
            var matches = CsProjRegex.Matches(csProjFileContents);

            foreach (Match match in matches)
            {
                ProcessCsProjFileMatch(match, csProjFileDirectoryPath, csProjFilesProcessed, csProjFilePaths);
            }
        }
Пример #2
0
        private static void RecurseProjFiles(string csProjFilePath, string[] csProjFilePaths, HashSet <string> csProjFilePathDependencyTree)
        {
            var csProjFileContents = File.ReadAllText(csProjFilePath);
            var matches            = CsProjRegex.Matches(csProjFileContents);

            foreach (Match match in matches)
            {
                var csProjDepFileName = ExtractCsProjName(match.Value);
                var csProjDepFilePath = FindCsProjFilePath(csProjFilePaths, csProjDepFileName);

                if (!csProjFilePathDependencyTree.Contains(csProjDepFilePath))
                {
                    csProjFilePathDependencyTree.Add(csProjDepFilePath);
                    RecurseProjFiles(csProjDepFilePath, csProjFilePaths, csProjFilePathDependencyTree);
                }
            }
        }
Пример #3
0
        private static void FixReferencesInProjectFile(string[] csProjFilePaths, string csProjFilePath)
        {
            var csProjFileContents = File.ReadAllText(csProjFilePath);
            var matches            = CsProjRegex.Matches(csProjFileContents);

            foreach (Match match in matches)
            {
                var csProjDepFileName         = ExtractCsProjName(match.Value);
                var csProjDepFilePath         = FindCsProjFilePath(csProjFilePaths, csProjDepFileName);
                var csProjDepRelativeFilePath = GetRelativePathTo(csProjFilePath, csProjDepFilePath);
                csProjFileContents = csProjFileContents.Replace(match.Value, $"Include=\"{csProjDepRelativeFilePath}\"");
            }

            if (csProjFileContents != File.ReadAllText(csProjFilePath))
            {
                File.WriteAllText(csProjFilePath, csProjFileContents);
                Console.WriteLine($"Fixed references in {csProjFilePath}");
            }
            else
            {
                Console.WriteLine($"No changes required in {csProjFilePath}");
            }
        }