internal ProjectFilesCollection(JsonObject rawProject,
                                        string projectDirectory,
                                        string projectFilePath,
                                        ICollection <ICompilationMessage> 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 FileFormatMessage(
                                     string.Format("Property \"{0}\" is deprecated. It is replaced by \"{1}\".", legacyPublishExcludePatternName, "publishExclude"),
                                     projectFilePath,
                                     CompilationMessageSeverity.Warning,
                                     legacyPublishExcludePatternToken));
                }
            }
            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);
        }
Exemple #2
0
        public static PatternGroup Build(JObject 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 <ICompilationMessage> warnings = null)
        {
            var token = rawProject[name];

            if (legacyName != null)
            {
                var legacyToken = rawProject[legacyName];
                if (legacyToken != null && token == null)
                {
                    token = legacyToken;
                    if (warnings != null)
                    {
                        warnings.Add(new FileFormatMessage(
                                         string.Format("Property \"{0}\" is deprecated. It is replaced by \"{1}\".", legacyName, name),
                                         projectFilePath,
                                         CompilationMessageSeverity.Warning,
                                         token));
                    }
                }
            }

            additionalIncluding = additionalIncluding ?? Enumerable.Empty <string>();
            var includePatterns = PatternsCollectionHelper.GetPatternsCollection(token, projectDirectory, projectFilePath, 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")
                                  .Distinct();

            return(new PatternGroup(includePatterns, excludePatterns, includeLiterals));
        }
Exemple #3
0
        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 <ICompilationMessage> warnings = null)
        {
            string includePropertyName = name;

            if (!rawProject.Keys.Contains(name) &&
                legacyName != null &&
                rawProject.Keys.Contains(legacyName))
            {
                includePropertyName = legacyName;
                if (warnings != null)
                {
                    warnings.Add(new FileFormatMessage(
                                     string.Format("Property \"{0}\" is deprecated. It is replaced by \"{1}\".", legacyName, name),
                                     projectFilePath,
                                     CompilationMessageSeverity.Warning,
                                     rawProject.Value(legacyName)));
                }
            }

            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")
                                  .Distinct();

            return(new PatternGroup(includePatterns, excludePatterns, includeLiterals));
        }