public bool ShouldProcessFile(string file) { file.ThrowIfNullOrWhiteSpace("file"); string extension = Path.GetExtension(file).ToLowerInvariant(); return(!ExtensionsToIgnore.Contains(extension)); }
private bool IgnoreFile(string path) { var extensionWithoutDot = Path.GetExtension(path).Substring(1); return(ExtensionsToIgnore.Contains(extensionWithoutDot)); }
private bool IsContentFile(ProjectItem bi, ProjectBase containingProject) { bool shouldSkipContent = false; if (bi.ItemType == "Folder" || bi.ItemType == "_DebugSymbolsOutputPath" || bi.ItemType == "Reference") { // Skip trying to add the folder. We don't need to do this because if it // contains anything, then the contained objects will automatically put themselves in a folder shouldSkipContent = true; } if (!shouldSkipContent) { if (bi.ItemType != "Compile" && bi.ItemType != "None") { // but wait, the containing project may embed its content, so if so we need to check that if (containingProject is CombinedEmbeddedContentProject && ((CombinedEmbeddedContentProject)containingProject).DefaultContentAction == bi.ItemType) { // Looks like it really is content shouldSkipContent = false; } else { shouldSkipContent = true; } } } if (!shouldSkipContent) { string extension = FileManager.GetExtension(bi.UnevaluatedInclude); if (ExtensionsToIgnore.Contains(extension)) { shouldSkipContent = true; } if (bi.ItemType == "Compile" && extension == "cs") { shouldSkipContent = true; } } // Now that we have checked if we should process this, we want to check if we should exclude it if (!shouldSkipContent) { var rfs = ObjectFinder.Self.GetReferencedFileSaveFromFile(bi.UnevaluatedInclude); if (rfs != null && rfs.ProjectsToExcludeFrom.Contains(this.Name)) { shouldSkipContent = true; } } if (!shouldSkipContent) { string containingProjectContent = FileManager.Standardize(containingProject.ContentDirectory).ToLowerInvariant(); string standardUnevaluatedInclude = FileManager.Standardize(bi.UnevaluatedInclude).ToLowerInvariant(); shouldSkipContent = standardUnevaluatedInclude.StartsWith(containingProjectContent) == false; } return(!shouldSkipContent); }
public override ProjectItem AddContentBuildItem(string absoluteFile, SyncedProjectRelativeType relativityType = SyncedProjectRelativeType.Linked, bool forceToContentPipeline = false) { /////////////////////////Early Out//////////////////////////// string extension = FileManager.GetExtension(absoluteFile); if (ExtensionsToIgnore.Contains(extension)) { return(null); } ///////////////////End Early Out////////////////////////////// lock (this) { string relativeFileName = FileManager.MakeRelative(absoluteFile, this.Directory); ProjectItem buildItem = null; bool addToContentPipeline = false; AssetTypeInfo assetTypeInfo = AvailableAssetTypes.Self.GetAssetTypeFromExtension(extension); if (assetTypeInfo != null) { addToContentPipeline = assetTypeInfo.MustBeAddedToContentPipeline || forceToContentPipeline; } // August 14, 2011 // Not sure why this // is here - I assume // because I thought when // I originally wrote this // that if something didn't // have an AssetTypeInfo, then // it couldn't be added to the content // pipeline...but I think CSVs can be. // So I'm going to remove this for now and // see what problems it causes. //if (forceToContentPipeline && assetTypeInfo == null) //{ // return; //} string itemInclude = FileManager.MakeRelative(absoluteFile, this.Directory); itemInclude = ProcessInclude(itemInclude); #region If added to content pipeline if (addToContentPipeline && AllowContentCompile) { buildItem = mProject.AddItem("Compile", ProcessInclude(itemInclude)).First(); mProject.ReevaluateIfNecessary(); if (string.IsNullOrEmpty(assetTypeInfo.ContentImporter) || string.IsNullOrEmpty(assetTypeInfo.ContentProcessor)) { throw new InvalidOperationException("There is missing import/process data for ." + extension + " files"); } buildItem.SetMetadataValue("Importer", assetTypeInfo.ContentImporter); buildItem.SetMetadataValue("Processor", assetTypeInfo.ContentProcessor); } #endregion #region else, just copy the file else { buildItem = mProject.AddItem(DefaultContentAction, itemInclude).FirstOrDefault(); mProject.ReevaluateIfNecessary(); if (ContentCopiedToOutput) { try { buildItem.SetMetadataValue("CopyToOutputDirectory", "PreserveNewest"); } catch (Exception exception) { throw new Exception("Error trying to add build item " + buildItem + " to project: " + exception.ToString()); } } } #endregion try { // The items in the dictionary must be to-lower on some // platforms, and ProcessPath takes care of this. mBuildItemDictionaries.Add(itemInclude.ToLower(), buildItem); } catch { int m = 3; } string name = FileManager.RemovePath(FileManager.RemoveExtension(relativeFileName)); buildItem.SetMetadataValue("Name", name); if (relativityType == SyncedProjectRelativeType.Linked) { string linkValue; string path = null; if (MasterProjectBase != null) { // OriginalProjectBaseIfSynced is the master project, but not sure why we check that if we already have // the MasterProjectBase. It was causing a NullReferenceException so I put an extra check. if (MasterProjectBase.OriginalProjectBaseIfSynced != null) { path = MasterProjectBase.OriginalProjectBaseIfSynced.ContentProject.FullContentPath; } else { path = MasterProjectBase.ContentProject.FullContentPath; } } // This will be null if we're creating a linked content file without a source project - which is the case for MonoGame projects // linking audio files: else if (OriginalProjectBaseIfSynced != null) { path = OriginalProjectBaseIfSynced.ContentProject.FullContentPath; } if (path != null) { linkValue = ContentDirectory + FileManager.MakeRelative(absoluteFile, path); linkValue = FileManager.RemoveDotDotSlash(linkValue); linkValue = ProcessInclude(linkValue); buildItem.SetMetadataValue("Link", linkValue); } } mProject.ReevaluateIfNecessary(); return(buildItem); } }