public void Add(ComboItem item) { var extension = Path.GetExtension(item.Value); if (extension == null) { return; } var importer = _importers.FindByName(extension.ToLower()); Add(item.Value, Path.GetFileNameWithoutExtension(item.Name), importer.Value, importer.Other); }
/// <summary> /// Adds a new content file to the MSBuild project. The importer and /// processor are optional: if you leave the importer null, it will /// be autodetected based on the file extension, and if you leave the /// processor null, data will be passed through without any processing. /// </summary> public void Add(string filename, string name, string importerString, string processor) { var fileExtension = Path.GetExtension(filename) ?? ""; var isContentBuildItem = !_secondaryImporters.ContainsKey(fileExtension); var importer = _importers.FindByName(fileExtension.ToLower()); if (isContentBuildItem) { importerString = importer.Value; processor = importer.Other; ProjectItem item = _buildProject.AddItem("Compile", filename)[0]; item.SetMetadataValue("Link", Path.GetFileName(filename)); item.SetMetadataValue("Name", name); if (!string.IsNullOrEmpty(importerString)) { item.SetMetadataValue("Importer", importerString); } if (!string.IsNullOrEmpty(processor)) { item.SetMetadataValue("Processor", processor); } _projectItems.Add(item); } else { var secondaryImporter = _secondaryImporters[fileExtension]; var fileTuple = new ImporterContext { AssetName = name + fileExtension, TargetDirectory = BuildArtifactsDirectory, SourceAssetDirectory = filename.Replace(name + fileExtension, "") }; secondaryImporter.Item2.Add(fileTuple); } }
public void Add(ComboItem item) { ComboItem importer = Importers.FindByName(System.IO.Path.GetExtension(item.Value).ToLower()); this.Add(item.Value, System.IO.Path.GetFileNameWithoutExtension(item.Name), importer.Value, importer.Other); }