本文整理汇总了C#中Microsoft.Build.Evaluation.ProjectItem.GetLink方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem.GetLink方法的具体用法?C# ProjectItem.GetLink怎么用?C# ProjectItem.GetLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Evaluation.ProjectItem
的用法示例。
在下文中一共展示了ProjectItem.GetLink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixLink
private static bool FixLink(ProjectItem 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;
}
示例2: AddAudioBuildItemToProject
private static bool AddAudioBuildItemToProject(ProjectBase project, ProjectItem 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.UnevaluatedInclude;
var link = buildItem.GetLink();
if(!string.IsNullOrEmpty( link ))
{
copiedXnb = ProjectManager.ProjectBase.Directory + "CopiedXnbs\\content\\" +
link;
}
copiedXnb = FileManager.RemoveDotDotSlash(copiedXnb);
string extension = FileManager.GetExtension(buildItem.UnevaluatedInclude);
bool isIos = project is IosMonogameProject;
bool isAndroid = project is AndroidProject;
string whatToAddToProject = null;
//
bool copyOriginalFile = (isIos || isAndroid) && FileManager.GetExtension(buildItem.UnevaluatedInclude) != "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.UnevaluatedInclude, 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.UnevaluatedInclude) + ".xnb";
}
if(project is AndroidProject)
{
linkToSet = "Assets\\" + linkToSet;
}
item.SetMetadataValue("Link", linkToSet);
PluginManager.ReceiveOutput("Added " + buildItem.EvaluatedInclude + " 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") &&
//.........这里部分代码省略.........