public static bool IsEvaluationMessage(string message) { return(SearchPathsForMSBuildExtensionsPath.IsMatch(message) || OverridingTarget.IsMatch(message) || TryingExtensionsPath.IsMatch(message) || ProjectImported.IsMatch(message) || DuplicateImport.IsMatch(message) || ProjectImportSkippedEmptyFile.IsMatch(message) || ProjectImportSkippedFalseCondition.IsMatch(message) || ProjectImportSkippedNoMatches.IsMatch(message) || ProjectImportSkippedMissingFile.IsMatch(message) || ProjectImportSkippedInvalidFile.IsMatch(message)); //Project "{0}" was not imported by "{1}" at({ 2},{ 3}), due to the file being empty. //ProjectImportSkippedFalseCondition $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to false condition; ({4}) was evaluated as ({5}). //ProjectImportSkippedNoMatches $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to no matching files. //ProjectImportSkippedMissingFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file not existing. //ProjectImportSkippedInvalidFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file being invalid. }
public static Match ProjectWasNotImportedRegex(string message, out string reason) { reason = ""; if (ProjectImportSkippedMissingFile.Match(message).Success) { reason = "the file not existing"; return(ProjectImportSkippedMissingFile.Match(message)); } else if (ProjectImportSkippedInvalidFile.Match(message).Success) { reason = "the file being invalid"; return(ProjectImportSkippedInvalidFile.Match(message)); } else if (ProjectImportSkippedEmptyFile.Match(message).Success) { reason = "the file being empty"; return(ProjectImportSkippedEmptyFile.Match(message)); } else if (ProjectImportSkippedNoMatches.Match(message).Success) { reason = "no matching files"; return(ProjectImportSkippedNoMatches.Match(message)); } else if (ProjectImportSkippedFalseCondition.Match(message).Success) { reason = "false condition; "; Match match = ProjectImportSkippedFalseCondition.Match(message); reason += match.Groups["Reason"].Value; reason += " was evaluated as " + match.Groups["Evaluated"].Value; return(match); } return(Match.Empty); //ProjectImportSkippedMissingFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file not existing. //ProjectImportSkippedInvalidFile $:$ Project "{0}" was not imported by "{1}" at({ 2},{3}), due to the file being invalid. //ProjectImportSkippedEmptyFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file being empty. //ProjectImportSkippedFalseCondition $:$ Project "{0}" was not imported by "{1}" at({ 2},{3}), due to false condition; ({4}) was evaluated as ({5}). //ProjectImportSkippedNoMatches $:$ Project "{0}" was not imported by "{1}" at({ 2},{3}), due to no matching files. }
private static void InitializeRegex() { OutputPropertyMessagePrefix = GetString("OutputPropertyLogMessage").Replace("{0}={1}", ""); BuildingWithToolsVersionPrefix = CreateRegex(GetString("ToolsVersionInEffectForBuild"), 1); PropertyGroupMessagePrefix = GetString("PropertyGroupLogMessage").Replace("{0}={1}", ""); ForSearchPathPrefix = CreateRegex(GetString("ResolveAssemblyReference.SearchPath"), 1); UnifiedPrimaryReferencePrefix = CreateRegex(GetString("ResolveAssemblyReference.UnifiedPrimaryReference"), 1); PrimaryReferencePrefix = CreateRegex(GetString("ResolveAssemblyReference.PrimaryReference"), 1); DependencyPrefix = CreateRegex(GetString("ResolveAssemblyReference.Dependency"), 1); UnifiedDependencyPrefix = CreateRegex(GetString("ResolveAssemblyReference.UnifiedDependency"), 1); AssemblyFoldersExLocation = CreateRegex(GetString("ResolveAssemblyReference.AssemblyFoldersExSearchLocations"), 1); AdditionalPropertiesPrefix = CreateRegex(GetString("General.AdditionalProperties"), 1); OverridingGlobalPropertiesPrefix = CreateRegex(GetString("General.OverridingProperties"), 1); TargetAlreadyCompleteSuccess = GetString("TargetAlreadyCompleteSuccess"); TargetAlreadyCompleteSuccessRegex = CreateRegex(TargetAlreadyCompleteSuccess, 1); TargetAlreadyCompleteFailure = GetString("TargetAlreadyCompleteFailure"); TargetAlreadyCompleteFailureRegex = CreateRegex(TargetAlreadyCompleteFailure, 1); TargetSkippedWhenSkipNonexistentTargets = CreateRegex(GetString("TargetSkippedWhenSkipNonexistentTargets"), 1); SkipTargetBecauseOutputsUpToDateRegex = CreateRegex(GetString("SkipTargetBecauseOutputsUpToDate"), 1); RemovingProjectProperties = CreateRegex(GetString("General.ProjectUndefineProperties"), 1); DuplicateImport = CreateRegex(GetString("SearchPathsForMSBuildExtensionsPath"), 3); SearchPathsForMSBuildExtensionsPath = CreateRegex(GetString("SearchPathsForMSBuildExtensionsPath"), 2); OverridingTarget = CreateRegex(GetString("OverridingTarget"), 4); TryingExtensionsPath = CreateRegex(GetString("TryingExtensionsPath"), 2); ProjectImported = GetString("ProjectImported"); string projectImported = "^" + ProjectImported .Replace(".", "\\.") .Replace("{0}", @"(?<ImportedProject>[^\""]+)") .Replace("{1}", @"(?<File>[^\""]+)") .Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)") + "$"; ProjectImportedRegex = new Regex(projectImported, RegexOptions.Compiled); TargetSkippedFalseCondition = GetString("TargetSkippedFalseCondition"); TargetSkippedFalseConditionRegex = CreateRegex(TargetSkippedFalseCondition, 3); TaskSkippedFalseCondition = GetString("TaskSkippedFalseCondition"); TaskSkippedFalseConditionRegex = CreateRegex(TaskSkippedFalseCondition, 3); TargetDoesNotExistBeforeTargetMessage = CreateRegex(GetString("TargetDoesNotExistBeforeTargetMessage"), 2); string copyingFileFrom = GetString("Copy.FileComment"); string copyingFileFromEscaped = Escape(copyingFileFrom); CopyingFileFromRegex = new Regex(copyingFileFromEscaped .Replace(@"\{0}", @"(?<From>[^\""]+)") .Replace(@"\{1}", @"(?<To>[^\""]+)") ); CreatingHardLinkRegex = new Regex(Escape(GetString("Copy.HardLinkComment")) .Replace(@"\{0}", @"(?<From>[^\""]+)") .Replace(@"\{1}", @"(?<To>[^\""]+)") ); DidNotCopyRegex = new Regex(Escape(GetString("Copy.DidNotCopyBecauseOfFileMatch")) .Replace(@"\{0}", @"(?<From>[^\""]+)") .Replace(@"\{1}", @"(?<To>[^\""]+)") .Replace(@"\{2}", ".*?") .Replace(@"\{3}", ".*?") ); ProjectImportSkippedMissingFile = GetString("ProjectImportSkippedMissingFile"); string skippedMissingFile = "^" + ProjectImportSkippedMissingFile .Replace(".", "\\.") .Replace("{0}", @"(?<ImportedProject>[^\""]+)") .Replace("{1}", @"(?<File>[^\""]+)") .Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)"); ProjectImportSkippedMissingFileRegex = new Regex(skippedMissingFile, RegexOptions.Compiled); ProjectImportSkippedInvalidFile = GetString("ProjectImportSkippedInvalidFile"); string skippedInvalidFile = "^" + ProjectImportSkippedInvalidFile .Replace(".", "\\.") .Replace("{0}", @"(?<ImportedProject>[^\""]+)") .Replace("{1}", @"(?<File>[^\""]+)") .Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)"); ProjectImportSkippedInvalidFileRegex = new Regex(skippedInvalidFile, RegexOptions.Compiled); ProjectImportSkippedEmptyFile = GetString("ProjectImportSkippedEmptyFile"); string skippedEmptyFile = "^" + ProjectImportSkippedEmptyFile .Replace(".", "\\.") .Replace("{0}", @"(?<ImportedProject>[^\""]+)") .Replace("{1}", @"(?<File>[^\""]+)") .Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)"); ProjectImportSkippedEmptyFileRegex = new Regex(skippedEmptyFile, RegexOptions.Compiled); ProjectImportSkippedNoMatches = GetString("ProjectImportSkippedNoMatches"); string skippedNoMatches = "^" + ProjectImportSkippedNoMatches .Replace(".", "\\.") .Replace("{0}", @"(?<ImportedProject>[^\""]+)") .Replace("{1}", @"(?<File>.*)") .Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)"); ProjectImportSkippedNoMatchesRegex = new Regex(skippedNoMatches, RegexOptions.Compiled); PropertyReassignment = GetString("PropertyReassignment"); string propertyReassignment = "^" + PropertyReassignment .Replace(@"$({0})=""{1}"" (", @"\$\((?<Name>\w+)\)="".*"" \(") .Replace(@"""{2}"")", @""".*""\)") .Replace("{3}", @"(?<File>.*) \((?<Line>\d+),(?<Column>\d+)\)$"); PropertyReassignmentRegex = new Regex(propertyReassignment, RegexOptions.Compiled | RegexOptions.Singleline); string taskFoundFromFactory = GetString("TaskFoundFromFactory") .Replace(@"""{0}""", @"\""(?<task>.+)\""") .Replace(@"""{1}""", @"\""(?<assembly>.+)\"""); TaskFoundFromFactory = new Regex("^" + taskFoundFromFactory, RegexOptions.Compiled); string taskFound = GetString("TaskFound") .Replace(@"""{0}""", @"\""(?<task>.+)\""") .Replace(@"""{1}""", @"\""(?<assembly>.+)\"""); TaskFound = new Regex("^" + taskFound, RegexOptions.Compiled); ProjectImportSkippedFalseCondition = GetString("ProjectImportSkippedFalseCondition"); string skippedFalseCondition = "^" + ProjectImportSkippedFalseCondition .Replace(".", "\\.") .Replace("{0}", @"(?<ImportedProject>[^\""]+)") .Replace("{1}", @"(?<File>[^\""]+)") .Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)") .Replace("{4}", "(?<Reason>.+)") .Replace("{5}", "(?<Evaluated>.+)"); ProjectImportSkippedFalseConditionRegex = new Regex(skippedFalseCondition, RegexOptions.Compiled); CouldNotResolveSdk = GetString("CouldNotResolveSdk"); CouldNotResolveSdkRegex = new Regex("^" + CouldNotResolveSdk .Replace("{0}", @"(?<Sdk>[^\""]+)"), RegexOptions.Compiled); ProjectImportSkippedExpressionEvaluatedToEmpty = GetString("ProjectImportSkippedExpressionEvaluatedToEmpty"); string emptyCondition = "^" + ProjectImportSkippedExpressionEvaluatedToEmpty .Replace(".", "\\.") .Replace("{0}", @"(?<ImportedProject>[^\""]+)") .Replace("{1}", @"(?<File>[^\""]+)") .Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)"); ProjectImportSkippedExpressionEvaluatedToEmptyRegex = new Regex(emptyCondition, RegexOptions.Compiled); ConflictReferenceSameSDK = CreateRegex(GetString("GetSDKReferenceFiles.ConflictReferenceSameSDK"), 3); ConflictRedistDifferentSDK = CreateRegex(GetString("GetSDKReferenceFiles.ConflictRedistDifferentSDK"), 5); ConflictReferenceDifferentSDK = CreateRegex(GetString("GetSDKReferenceFiles.ConflictRedistDifferentSDK"), 4); ConflictFoundRegex = new Regex(Escape(GetString("ResolveAssemblyReference.ConflictFound")) .Replace(@"\{0}", ".*?") .Replace(@"\{1}", ".*?") + ".*", RegexOptions.Compiled); var foundConflictsRaw = GetString("ResolveAssemblyReference.FoundConflicts"); if (foundConflictsRaw.StartsWith("MSB3277: ")) { foundConflictsRaw = foundConflictsRaw.Substring("MSB3277: ".Length); } var foundConflictsNormalized = foundConflictsRaw.NormalizeLineBreaks(); var foundConflictsEscaped = Escape(foundConflictsNormalized); FoundConflictsRegex = new Regex(foundConflictsEscaped .Replace(@"\{0}", @"(?<Assembly>[^\""]*)") .Replace(@"\{1}", @"(?<Details>.*)"), RegexOptions.Compiled | RegexOptions.Singleline); TaskParameterMessagePrefix = GetString("TaskParameterPrefix"); OutputItemsMessagePrefix = GetString("OutputItemParameterMessagePrefix"); ItemGroupIncludeMessagePrefix = GetString("ItemGroupIncludeLogMessagePrefix"); ItemGroupRemoveMessagePrefix = GetString("ItemGroupRemoveLogMessage"); GlobalPropertiesPrefix = GetString("General.GlobalProperties"); RemovingPropertiesPrefix = GetString("General.UndefineProperties"); EvaluationStarted = GetString("EvaluationStarted"); EvaluationFinished = GetString("EvaluationFinished"); }