本文整理汇总了C#中Microsoft.Build.Utilities.TaskItem.RemoveMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# TaskItem.RemoveMetadata方法的具体用法?C# TaskItem.RemoveMetadata怎么用?C# TaskItem.RemoveMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Utilities.TaskItem
的用法示例。
在下文中一共展示了TaskItem.RemoveMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetItemMetadata
//.........这里部分代码省略.........
// was no IsRedistRoot flag in the Redist XML (or there was no
// redist XML at all for this item).
}
// If there was a primary source item, then forward metadata from it.
// It's important that the metadata from the primary source item
// win over the same metadata from other source items, so that's
// why we put this first. (CopyMetadataTo will never override an
// already existing metadata.) For example, if this reference actually
// came directly from an item declared in the project file, we'd
// want to use the metadata from it, not some other random item in
// the project file that happened to have this reference as a dependency.
if (reference.PrimarySourceItem != null)
{
reference.PrimarySourceItem.CopyMetadataTo(referenceItem);
}
else
{
bool hasImplementationFile = referenceItem.GetMetadata(ItemMetadataNames.winmdImplmentationFile).Length > 0;
bool hasImageRuntime = referenceItem.GetMetadata(ItemMetadataNames.imageRuntime).Length > 0;
bool hasWinMDFile = referenceItem.GetMetadata(ItemMetadataNames.winMDFile).Length > 0;
// If there were non-primary source items, then forward metadata from them.
ICollection sourceItems = reference.GetSourceItems();
foreach (ITaskItem sourceItem in sourceItems)
{
sourceItem.CopyMetadataTo(referenceItem);
}
// If the item originally did not have the implementation file metadata then we do not want to get it from the set of primary source items
// since the implementation file is something specific to the source item and not supposed to be propigated.
if (!hasImplementationFile)
{
referenceItem.RemoveMetadata(ItemMetadataNames.winmdImplmentationFile);
}
// If the item originally did not have the ImageRuntime metadata then we do not want to get it from the set of primary source items
// since the ImageRuntime is something specific to the source item and not supposed to be propigated.
if (!hasImageRuntime)
{
referenceItem.RemoveMetadata(ItemMetadataNames.imageRuntime);
}
// If the item originally did not have the WinMDFile metadata then we do not want to get it from the set of primary source items
// since the WinMDFile is something specific to the source item and not supposed to be propigated
if (!hasWinMDFile)
{
referenceItem.RemoveMetadata(ItemMetadataNames.winMDFile);
}
}
if (reference.ReferenceVersion != null)
{
referenceItem.SetMetadata(ItemMetadataNames.version, reference.ReferenceVersion.ToString());
}
else
{
referenceItem.SetMetadata(ItemMetadataNames.version, String.Empty);
}
// Now clone all properties onto the related files.
foreach (string relatedFileExtension in reference.GetRelatedFileExtensions())
{
ITaskItem item = new TaskItem(reference.FullPathWithoutExtension + relatedFileExtension);
// Clone metadata.
referenceItem.CopyMetadataTo(item);
示例2: CannotRemoveModifiers
public void CannotRemoveModifiers()
{
TaskItem t = new TaskItem("foor");
try
{
t.RemoveMetadata(FileUtilities.ItemSpecModifiers.RootDir);
}
catch (Exception e)
{
// so I can see the exception message in NUnit's "Standard Out" window
Console.WriteLine(e.Message);
throw;
}
}