Exemple #1
0
        private static async IAsyncEnumerable <string> GetRelevantProjectFilesAsync(string solutionDir, string version,
                                                                                    string commonAssemblyPath)
        {
            if (!(await FileOperationHelper.GetFilesAsync(solutionDir, FileTypeAssembly, SearchOption.AllDirectories) is
                  List <string> filesPaths))
            {
                yield break;
            }

            filesPaths.Remove(commonAssemblyPath);

            filesPaths.RemoveAll(s => IgnoreDirs.Any(s.StartsWith));

            IAsyncEnumerable <string> filteredFilePaths = FilterAssemblyFilesByVersionAsync(filesPaths, version);

            await foreach (string filteredFilePath in filteredFilePaths)
            {
                string path = Directory.GetParent(Directory.GetParent(filteredFilePath).FullName).FullName;
                yield return(Directory.GetFiles(path, FileTypeProject, SearchOption.TopDirectoryOnly)
                             .FirstOrDefault());
            }
        }
Exemple #2
0
        private static async Task UpdateAssemblyInfoFileAsync(string projectFilePath, string commonAssemblyPath)
        {
            string assemblyInfoFilePath = await FileOperationHelper.GetAssemblyInfoFilePathFromProject(projectFilePath);

            string[] commonAssemblyInfoContent = await File.ReadAllLinesAsync(commonAssemblyPath);

            IEnumerable <string> assemblyInfoContentLines =
                from line in commonAssemblyInfoContent
                let pattern = "[assembly: Assembly"
                              where line.StartsWith(pattern)
                              let regex = new Regex(@"(?<line>^\[assembly: Assembly\w+\()", RegexOptions.Multiline)
                                          select regex.Match(line)
                                          into match
                                              where match.Success
                                          select match.Captures.FirstOrDefault()?.Value;

            string assemblyInfoContent = assemblyInfoContentLines.Aggregate(
                await File.ReadAllTextAsync(assemblyInfoFilePath),
                (current, s) =>
                current.Replace($"\r\n{s ?? throw new InvalidOperationException()}", $"\r\n// {s}"));

            await FileOperationHelper.WriteAllTextAsync(assemblyInfoFilePath, assemblyInfoContent);
        }