private static void HasEnableNetAnalyzers( bool throwIf, ILogger logger, DirectoryInfo projectPath, SupportedProjectTargetType projectTarget) { var foundFiles = DotnetCsProjHelper.SearchAllForElement( projectPath, "EnableNETAnalyzers", "true", SearchOption.AllDirectories, StringComparison.OrdinalIgnoreCase); if (!foundFiles.Any()) { return; } var sb = new StringBuilder(); var header = $"EnableNETAnalyzers in .csproj causes build errors when /Directory.Build.Props has projectTarget '{projectTarget}', please remove the element from 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()); } }
public static void CheckFiles( bool throwIf, ILogger logger, DirectoryInfo projectPath, SupportedProjectTargetType projectTarget) { MissingOrganizationName(logger, projectPath); MissingRepositoryName(logger, projectPath); switch (projectTarget) { case SupportedProjectTargetType.DotNet5: HasEnableNetAnalyzers(throwIf, logger, projectPath, projectTarget); break; case SupportedProjectTargetType.DotNet6: HasTargetFrameworkAndImplicitUsings(throwIf, logger, projectPath, "netcoreapp3.1"); break; } }
private static string CreateArgumentProjectTarget(SupportedProjectTargetType targetType) => @$ "{ArgumentCommandConstants.ShortProjectTarget} {targetType}";