Esempio n. 1
0
        public override bool Execute()
        {
            Log.LogMessage("Building content:");

            XBuildLogger    logger   = new XBuildLogger(this.Log);
            ContentCompiler compiler = new ContentCompiler(PipelineAssemblies);

            foreach (ITaskItem sourceItem in SourceAssets)
            {
                //foreach (string name in sourceItem.MetadataNames)
                //	Log.LogMessage(name + " : " + sourceItem.GetMetadata(name));
                string assetName = sourceItem.GetMetadata("Name");

                Log.LogMessage("Building " + assetName);

                Stream        outputStream  = new FileStream(OutputDirectory + assetName + ".xnb", FileMode.OpenOrCreate);
                ContentWriter contentWriter = new ContentWriter(outputStream, getTargetPlatform(), CompressContent);

                string importerName  = sourceItem.GetMetadata("Importer");
                string processorName = sourceItem.GetMetadata("Processor");

                IContentImporter importer = getImporterInstance(importerName);
                if (importer == null)
                {
                    Log.LogError("Could not find the importer (" + importerName + ")");
                }

                IContentProcessor processor = getProcessorInstance(processorName);
                if (importer == null)
                {
                    Log.LogError("Could not find the processor (" + processorName + ")");
                }

                Log.LogMessage("Using " + importerName + " and " + processorName);

                ContentImporterContext  importerContext  = new ContentImporterContext(this, IntermediateDirectory, OutputDirectory, logger);
                ContentProcessorContext processorContext = new ContentProcessorContext();

                processor.Process(importer.Import(sourceItem.GetMetadata("Include"), importerContext), processorContext);
            }

            return(true);
        }
Esempio n. 2
0
		public override bool Execute()
		{
			Log.LogMessage("Building content:");
			
			XBuildLogger logger = new XBuildLogger(this.Log);
			ContentCompiler compiler = new ContentCompiler(PipelineAssemblies);
		
			foreach (ITaskItem sourceItem in SourceAssets)
			{
				//foreach (string name in sourceItem.MetadataNames)
				//	Log.LogMessage(name + " : " + sourceItem.GetMetadata(name));
				string assetName = sourceItem.GetMetadata("Name");
				
				Log.LogMessage("Building " + assetName);
				
				Stream outputStream = new FileStream(OutputDirectory + assetName + ".xnb", FileMode.OpenOrCreate);
				ContentWriter contentWriter = new ContentWriter(outputStream, getTargetPlatform(), CompressContent);
				
				string importerName = sourceItem.GetMetadata("Importer");
				string processorName = sourceItem.GetMetadata("Processor");
				
				IContentImporter importer = getImporterInstance(importerName);
				if (importer == null)
					Log.LogError("Could not find the importer (" + importerName + ")");
				
				IContentProcessor processor = getProcessorInstance(processorName);
				if (importer == null)
					Log.LogError("Could not find the processor (" + processorName + ")");
				
				Log.LogMessage("Using " + importerName + " and " + processorName);
				
				ContentImporterContext importerContext = new ContentImporterContext(this, IntermediateDirectory, OutputDirectory, logger);
				ContentProcessorContext processorContext = new ContentProcessorContext();
				
				processor.Process(importer.Import(sourceItem.GetMetadata("Include"), importerContext), processorContext);
			}
				
			return true;
		}