internal static PatternGroup Build(JsonObject rawProject, string projectDirectory, string projectFilePath, string name, IEnumerable <string> fallbackIncluding = null, IEnumerable <string> additionalIncluding = null, IEnumerable <string> additionalExcluding = null, bool includePatternsOnly = false, ICollection <DiagnosticMessage> warnings = null) { string includePropertyName = name; additionalIncluding = additionalIncluding ?? Enumerable.Empty <string>(); var includePatterns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, includePropertyName, defaultPatterns: fallbackIncluding) .Concat(additionalIncluding) .Distinct(); if (includePatternsOnly) { return(new PatternGroup(includePatterns)); } additionalExcluding = additionalExcluding ?? Enumerable.Empty <string>(); var excludePatterns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, propertyName: name + "Exclude") .Concat(additionalExcluding) .Distinct(); var includeLiterals = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, propertyName: name + "Files", literalPath: true) .Distinct(); return(new PatternGroup(includePatterns, excludePatterns, includeLiterals)); }
internal ProjectFilesCollection(JsonObject rawProject, string projectDirectory, string projectFilePath, ICollection <DiagnosticMessage> warnings = null) { _projectDirectory = projectDirectory; _projectFilePath = projectFilePath; var excludeBuiltIns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, "excludeBuiltIn", DefaultBuiltInExcludePatterns); var excludePatterns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, "exclude") .Concat(excludeBuiltIns); var contentBuiltIns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, "contentBuiltIn", DefaultContentsBuiltInPatterns); var compileBuiltIns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, "compileBuiltIn", DefaultCompileBuiltInPatterns); var resourceBuiltIns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, "resourceBuiltIn", DefaultResourcesBuiltInPatterns); // TODO: The legacy names will be retired in the future. var legacyPublishExcludePatternName = "bundleExclude"; var legacyPublishExcludePatternToken = rawProject.ValueAsJsonObject(legacyPublishExcludePatternName); if (legacyPublishExcludePatternToken != null) { _publishExcludePatterns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, legacyPublishExcludePatternName, DefaultPublishExcludePatterns); if (warnings != null) { warnings.Add(new DiagnosticMessage( string.Format("Property \"{0}\" is deprecated. It is replaced by \"{1}\".", legacyPublishExcludePatternName, "publishExclude"), projectFilePath, DiagnosticMessageSeverity.Warning, legacyPublishExcludePatternToken.Line, legacyPublishExcludePatternToken.Column)); } } else { _publishExcludePatterns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, "publishExclude", DefaultPublishExcludePatterns); } _sharedPatternsGroup = PatternGroup.Build(rawProject, projectDirectory, projectFilePath, "shared", legacyName: null, warnings: warnings, fallbackIncluding: DefaultSharedPatterns, additionalExcluding: excludePatterns); _resourcePatternsGroup = PatternGroup.Build(rawProject, projectDirectory, projectFilePath, "resource", "resources", warnings: warnings, additionalIncluding: resourceBuiltIns, additionalExcluding: excludePatterns); _preprocessPatternsGroup = PatternGroup.Build(rawProject, projectDirectory, projectFilePath, "preprocess", legacyName: null, warnings: warnings, fallbackIncluding: DefaultPreprocessPatterns, additionalExcluding: excludePatterns) .ExcludeGroup(_sharedPatternsGroup) .ExcludeGroup(_resourcePatternsGroup); _compilePatternsGroup = PatternGroup.Build(rawProject, projectDirectory, projectFilePath, "compile", "code", warnings: warnings, additionalIncluding: compileBuiltIns, additionalExcluding: excludePatterns) .ExcludeGroup(_sharedPatternsGroup) .ExcludeGroup(_preprocessPatternsGroup) .ExcludeGroup(_resourcePatternsGroup); _contentPatternsGroup = PatternGroup.Build(rawProject, projectDirectory, projectFilePath, "content", "files", warnings: warnings, additionalIncluding: contentBuiltIns, additionalExcluding: excludePatterns.Concat(_publishExcludePatterns)) .ExcludeGroup(_compilePatternsGroup) .ExcludeGroup(_preprocessPatternsGroup) .ExcludeGroup(_sharedPatternsGroup) .ExcludeGroup(_resourcePatternsGroup); _namedResources = NamedResourceReader.ReadNamedResources(rawProject, projectFilePath); }
internal void EnsureInitialized() { if (_initialized) { return; } var excludeBuiltIns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "excludeBuiltIn", DefaultBuiltInExcludePatterns); var excludePatterns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "exclude") .Concat(excludeBuiltIns); var contentBuiltIns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "contentBuiltIn", DefaultContentsBuiltInPatterns); var compileBuiltIns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "compileBuiltIn", DefaultCompileBuiltInPatterns); var resourceBuiltIns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "resourceBuiltIn", DefaultResourcesBuiltInPatterns); _publishExcludePatterns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "publishExclude", DefaultPublishExcludePatterns); _sharedPatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "shared", fallbackIncluding: DefaultSharedPatterns, additionalExcluding: excludePatterns); _resourcePatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "resource", additionalIncluding: resourceBuiltIns, additionalExcluding: excludePatterns); _preprocessPatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "preprocess", fallbackIncluding: DefaultPreprocessPatterns, additionalExcluding: excludePatterns) .ExcludeGroup(_sharedPatternsGroup) .ExcludeGroup(_resourcePatternsGroup); _compilePatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "compile", additionalIncluding: compileBuiltIns, additionalExcluding: excludePatterns) .ExcludeGroup(_sharedPatternsGroup) .ExcludeGroup(_preprocessPatternsGroup) .ExcludeGroup(_resourcePatternsGroup); _contentPatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "content", additionalIncluding: contentBuiltIns, additionalExcluding: excludePatterns.Concat(_publishExcludePatterns)) .ExcludeGroup(_compilePatternsGroup) .ExcludeGroup(_preprocessPatternsGroup) .ExcludeGroup(_sharedPatternsGroup) .ExcludeGroup(_resourcePatternsGroup); _namedResources = NamedResourceReader.ReadNamedResources(_rawProject, _projectFilePath); // Files to be packed along with the project var packIncludeJson = _rawProject.ValueAsJsonObject(PackIncludePropertyName); if (packIncludeJson != null) { _packInclude = packIncludeJson .Keys .Select(k => new PackIncludeEntry(k, packIncludeJson.Value(k))) .ToList(); } else { _packInclude = new List <PackIncludeEntry>(); } _initialized = true; _rawProject = null; }
internal static PatternGroup Build(JsonObject rawProject, string projectDirectory, string projectFilePath, string name, string legacyName, IEnumerable <string> fallbackIncluding = null, IEnumerable <string> additionalIncluding = null, IEnumerable <string> additionalExcluding = null, bool includePatternsOnly = false, ICollection <DiagnosticMessage> warnings = null) { string includePropertyName = name; if (!rawProject.Keys.Contains(name) && legacyName != null && rawProject.Keys.Contains(legacyName)) { includePropertyName = legacyName; if (warnings != null) { var legacyToken = rawProject.Value(legacyName); warnings.Add(new DiagnosticMessage( $"Property \"{legacyName}\" is deprecated. It is replaced by \"{name}\".", projectFilePath, DiagnosticMessageSeverity.Warning, legacyToken.Line, legacyToken.Column)); } } additionalIncluding = additionalIncluding ?? Enumerable.Empty <string>(); var includePatterns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, includePropertyName, defaultPatterns: fallbackIncluding) .Concat(additionalIncluding) .Distinct(); if (includePatternsOnly) { return(new PatternGroup(includePatterns)); } additionalExcluding = additionalExcluding ?? Enumerable.Empty <string>(); var excludePatterns = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, propertyName: name + "Exclude") .Concat(additionalExcluding) .Distinct(); var includeLiterals = PatternsCollectionHelper.GetPatternsCollection(rawProject, projectDirectory, projectFilePath, propertyName: name + "Files", literalPath: true) .Distinct(); return(new PatternGroup(includePatterns, excludePatterns, includeLiterals)); }