private static void HasTargetFrameworkAndImplicitUsings( bool throwIf, ILogger logger, DirectoryInfo projectPath, string targetFramework) { var foundDirectoryBuildPropsFilesWithImplicitUsings = DirectoryBuildPropsHelper.SearchAllForElement( projectPath, "ImplicitUsings", "enable", SearchOption.TopDirectoryOnly, StringComparison.OrdinalIgnoreCase); if (!foundDirectoryBuildPropsFilesWithImplicitUsings.Any()) { return; } var foundFiles = DotnetCsProjHelper.SearchAllForElement( projectPath, "TargetFramework", targetFramework); if (!foundFiles.Any()) { return; } var sb = new StringBuilder(); var header = $"TargetFramework '{targetFramework}' in .csproj can causes build errors when /Directory.Build.Props has ImplicitUsings enabled, please manually upgrade the following files:"; if (throwIf) { sb.AppendLine(header); } else { logger.LogWarning(header); } foreach (var fileFullName in foundFiles.Select(x => x.FullName)) { if (throwIf) { sb.AppendLine(5, fileFullName); } else { logger.LogWarning($" {fileFullName}"); } } if (throwIf) { throw new DataException(sb.ToString()); } }
private static void MissingRepositoryName( ILogger logger, DirectoryInfo projectPath) { var foundFiles = DirectoryBuildPropsHelper.SearchAllForElement( projectPath, "RepositoryName", "<!-- insert repository name here -->", SearchOption.TopDirectoryOnly); if (!foundFiles.Any()) { return; } logger.LogWarning($"RepositoryName in /{DirectoryBuildPropsHelper.FileName} is not set yet, please fix"); }