本文整理汇总了C#中TaskItem.CopyMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# TaskItem.CopyMetadata方法的具体用法?C# TaskItem.CopyMetadata怎么用?C# TaskItem.CopyMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskItem
的用法示例。
在下文中一共展示了TaskItem.CopyMetadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override bool Execute()
{
try
{
List<ITaskItem> contentsList = new List<ITaskItem>();
List<ITaskItem> dependencyList = new List<ITaskItem>();
List<ITaskItem> templateList = new List<ITaskItem>();
HashSet<Guid> guids = new HashSet<Guid>();
ProjectEx.Task = this;
foreach (ITaskItem projectItem in projectFiles)
{
string currentDirectory = Environment.CurrentDirectory;
ProjectEx project = new ProjectEx(projectItem);
project.Load();
Environment.CurrentDirectory = Path.GetDirectoryName(
project.FullFileName);
//Retrieve the list of Guids defined in the project, for later replacement.
string projectGuid = project.GetEvaluatedProperty("ProjectGuid");
if (!string.IsNullOrEmpty(projectGuid))
{
try
{
Guid guidProject = new Guid(projectGuid);
if (!guids.Contains(guidProject))
{
guids.Add(guidProject);
}
}
catch (FormatException)
{
Log.LogWarning("Project {0} has specified an ProjectGuid property not in the format of a Guid.", projectItem.ItemSpec);
}
}
string emulatorId = project.GetEvaluatedProperty("EmulatorId");
if (!string.IsNullOrEmpty(emulatorId))
{
try
{
Guid guidEmulator = new Guid(emulatorId);
if (!guids.Contains(guidEmulator))
{
guids.Add(guidEmulator);
}
}
catch (FormatException)
{
Log.LogWarning("Project {0} has specified an EmulatorId property not in the format of a Guid.", projectItem.ItemSpec);
}
}
//Select all the files referenced by the project.
foreach (string groupName in ProjectEx.FileGroups)
{
foreach (_BE.ProjectItem buildItem in project.MsBuildProject.GetItemsIgnoringCondition(groupName))
{
if (TransmorgificationUtilities.IsInRestrictedList(buildItem.Xml.Include))
{
Log.LogMessage("Skipping restricted file {0} in project {1}", buildItem.EvaluatedInclude, projectItem.ItemSpec);
continue;
}
else if (!File.Exists(buildItem.EvaluatedInclude)) // .GetMetadata("FullPath").EvaluatedValue))
{
Log.LogWarning("Cannot find file {0} referenced in project {1}", buildItem.EvaluatedInclude, projectItem.ItemSpec);
continue;
}
string fileName = buildItem.EvaluatedInclude;
if (Path.IsPathRooted(fileName))
{
Log.LogWarning("Project {0} references file {1} by absolute path, which is unsuitable for samples and templates", projectItem.ItemSpec, fileName);
}
TaskItem file = new TaskItem(fileName);
bool doReplacements = TransmorgificationUtilities.ValidMimeTypeForReplacements(buildItem.Xml.Include);
file.CopyMetadata(buildItem);
file.SetMetadata("DoReplacements", doReplacements.ToString().ToLowerInvariant());
file.SetMetadata("ItemCollection", buildItem.ItemType);
file.SetMetadata("ParentProject", projectItem.ItemSpec);
file.SetMetadata("ProjectDir", projectItem.GetMetadata("RelativeDir"));
string rootNamespace = project.GetEvaluatedProperty("RootNamespace");
if (rootNamespace == null)
{
rootNamespace = "";
}
file.SetMetadata("RootNamespace", rootNamespace);
contentsList.Add(file);
}
}
string templateIconFile = project.GetEvaluatedProperty("TemplateIconFile");
if (!string.IsNullOrEmpty(templateIconFile))
{
//.........这里部分代码省略.........