当前位置: 首页>>代码示例>>C#>>正文


C# BuildItem.GetLink方法代码示例

本文整理汇总了C#中Microsoft.Build.BuildEngine.BuildItem.GetLink方法的典型用法代码示例。如果您正苦于以下问题:C# BuildItem.GetLink方法的具体用法?C# BuildItem.GetLink怎么用?C# BuildItem.GetLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.BuildEngine.BuildItem的用法示例。


在下文中一共展示了BuildItem.GetLink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixLink

        private static bool FixLink(BuildItem item, ProjectBase project)
        {
            bool didFix = false;

            string oldLink = item.GetLink();
            string newLink = project.ProcessLink(oldLink);

            if (oldLink != newLink)
            {
                item.SetLink(newLink);
                didFix = true;
            }


            return didFix;
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:16,代码来源:XnbContentAdder.cs

示例2: AddAudioBuildItemToProject

        private static bool AddAudioBuildItemToProject(ProjectBase project, BuildItem buildItem)
        {
            bool wasAnythingChanged = false;
            // This item needs an associated entry in the project
            // The item will be relative to the main project as opposed
            // to the content project, inside the CopiedXnbs directory:
            string copiedXnb = ProjectManager.ProjectBase.Directory + "CopiedXnbs\\content\\" +
                buildItem.Include;

            var link = buildItem.GetLink();
            if(!string.IsNullOrEmpty( link ))
            {
                copiedXnb = ProjectManager.ProjectBase.Directory + "CopiedXnbs\\content\\" +
                    link;
            }

            copiedXnb = FileManager.RemoveDotDotSlash(copiedXnb);

            string extension = FileManager.GetExtension(buildItem.Include);

            bool isIos = project is IosMonogameProject;
            bool isAndroid = project is AndroidProject;

            string whatToAddToProject = null;

            // 
            bool copyOriginalFile = (isIos || isAndroid) && FileManager.GetExtension(buildItem.Include) != "wav";

            if (copyOriginalFile)
            {
                // Jan 1, 2014
                // Not sure why
                // we were making
                // this file absolute
                // using the synced project's
                // directory.  The file will be
                // shared by synced and original
                // projects so the file needs to be
                // made absolute according to that project.
                //whatToAddToProject = project.MakeAbsolute("content/" + buildItem.Include);
                whatToAddToProject = ProjectManager.MakeAbsolute("content/" + buildItem.Include, true);
            }
            else
            {
                whatToAddToProject = copiedXnb;
            }
            // Both sound and music files have XNBs associated with them so let's add that:
            whatToAddToProject = FileManager.RemoveExtension(whatToAddToProject) + ".xnb";
            copiedXnb = FileManager.RemoveExtension(copiedXnb) + ".xnb";


            var item = project.GetItem(whatToAddToProject, true);
            if (item == null)
            {
                item = project.AddContentBuildItem(whatToAddToProject, SyncedProjectRelativeType.Linked, false);

                string linkToSet = null;

                if (!string.IsNullOrEmpty(buildItem.GetLink()))
                {
                    linkToSet = "Content\\" + FileManager.RemoveExtension(buildItem.GetLink()) + ".xnb";
                }
                else
                {
                    linkToSet = "Content\\" + FileManager.RemoveExtension(buildItem.Include) + ".xnb";
                }

                if(project is AndroidProject)
                {
                    linkToSet = "Assets\\" + linkToSet;
                }

                item.SetMetadata("Link", linkToSet);


                PluginManager.ReceiveOutput("Added " + buildItem.Include + " through the file " + whatToAddToProject);
                wasAnythingChanged = true;
            }

            wasAnythingChanged |= FixLink(item, project);


            if (isIos && extension == "mp3")
            {
                if (FileManager.FileExists(copiedXnb))
                {
                    ReplaceWmaReferenceToMp3ReferenceInXnb(copiedXnb, whatToAddToProject);
                }
                
            }

            // I think we want to tell the user that the XNB is missing so they know to build the PC project
            if(!FileManager.FileExists(copiedXnb))
            {

                PluginManager.ReceiveError("XNB file is missing - try rebuilding PC project: " + copiedXnb);
            }

            // Music files also have a wma file:
            if ((extension == "mp3" || extension == "wma") && 
//.........这里部分代码省略.........
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:101,代码来源:XnbContentAdder.cs


注:本文中的Microsoft.Build.BuildEngine.BuildItem.GetLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。