Example #1
0
 public override ProjectItem AddContentBuildItem(string absoluteFile, SyncedProjectRelativeType relativityType, bool forceToContentPipeline)
 {
     throw new NotImplementedException();
 }
        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);
            }
        }
Example #3
0
 public override BuildItem AddContentBuildItem(string absoluteFile, SyncedProjectRelativeType relativityType, bool forceToContentPipeline)
 {
     throw new NotImplementedException("You can't sync a eclipse project with a VS project!"); 
 }
Example #4
0
 public override BuildItem AddContentBuildItem(string absoluteFile, SyncedProjectRelativeType relativityType, bool forceToContentPipeline)
 {
     throw new NotImplementedException();
 }
Example #5
0
 /// <summary>
 /// Adds the argument absoluteFile to the project. This method will not first check
 /// if the file is already part of the project or not. See IsFilePartOfProject for
 /// checking if the file is already part of the project.
 /// </summary>
 /// <param name="absoluteFile">The absolute file name to add.</param>
 /// <returns>The ProjectItem which was created and added to the project.</returns>
 public abstract ProjectItem AddContentBuildItem(string absoluteFile, SyncedProjectRelativeType relativityType = SyncedProjectRelativeType.Contained, bool forceToContentPipeline = false);
        public override ProjectItem AddContentBuildItem(string absoluteFile, SyncedProjectRelativeType relativityType = SyncedProjectRelativeType.Linked, bool forceToContentPipeline = false)
        {
            lock (this)
            {
                string relativeFileName = FileManager.MakeRelative(absoluteFile, this.Directory);

                ProjectItem buildItem = null;

                bool addToContentPipeline = false;
                string extension = FileManager.GetExtension(absoluteFile);
                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();

                    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, ProcessInclude(itemInclude)).FirstOrDefault();
                    if (ContentCopiedToOutput)
                        buildItem.SetMetadataValue("CopyToOutputDirectory", "PreserveNewest");
                }

                #endregion
                try
                {
                    // The items in the dictionary must be to-lower on some
                    // platforms, and ProcessPath takes care of this.
                    mBuildItemDictionaries.Add(ProcessInclude(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;

                    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;
                        }
                    }
                    else
                        path = OriginalProjectBaseIfSynced.ContentProject.FullContentPath;

                    linkValue = ContentDirectory + FileManager.MakeRelative(absoluteFile, path);
                    linkValue = FileManager.RemoveDotDotSlash(linkValue);
                    linkValue = ProcessInclude(linkValue);



                    buildItem.SetMetadataValue("Link", linkValue);
                }

                return buildItem;
            }
        }