本文整理汇总了C#中Microsoft.Build.Evaluation.SetMetadataValue方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Build.Evaluation.SetMetadataValue方法的具体用法?C# Microsoft.Build.Evaluation.SetMetadataValue怎么用?C# Microsoft.Build.Evaluation.SetMetadataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Evaluation
的用法示例。
在下文中一共展示了Microsoft.Build.Evaluation.SetMetadataValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetMetadataValue
public static void SetMetadataValue(MSBuild.ProjectItem item, string name, string value)
{
item.SetMetadataValue(name, value);
}
示例2: ReplaceGuidMetadataIfExists
private void ReplaceGuidMetadataIfExists(_BE.ProjectItem item, string metadataName)
{
string value = item.GetMetadata(metadataName).EvaluatedValue;
if (!string.IsNullOrEmpty(value))
{
try
{
Guid g = new Guid(value);
string replaceWith;
if (guidDictionary.TryGetValue(g, out replaceWith))
{
//VS Guid replacements don't include braces
replaceWith = "{" + replaceWith + "}";
item.SetMetadataValue(metadataName, replaceWith);
}
}
catch (FormatException)
{
Log.LogWarning("Item {0} has specified {1} metadata not in the format of a Guid.", item.EvaluatedInclude, metadataName);
}
}
}
示例3: AddIndependentFileNode
/// <summary>
/// Add an item to the hierarchy based on the item path
/// </summary>
/// <param name="item">Item to add</param>
/// <returns>Added node</returns>
protected virtual HierarchyNode AddIndependentFileNode(MSBuild.ProjectItem item, IDictionary<string, HierarchyNode> parentNodeCache)
{
if (item == null)
throw new ArgumentNullException("item");
if (parentNodeCache == null)
throw new ArgumentNullException("parentNodeCache");
//Contract.Ensures(Contract.Result<HierarchyNode>() != null);
// Make sure the item is within the project folder hierarchy. If not, link it.
string linkPath = item.GetMetadataValue(ProjectFileConstants.Link);
if (String.IsNullOrEmpty(linkPath))
{
string projectFolder = new Uri(this.ProjectFolder).LocalPath;
string itemPath = new Uri(Path.Combine(this.ProjectFolder, item.EvaluatedInclude)).LocalPath;
if (!itemPath.StartsWith(projectFolder, StringComparison.OrdinalIgnoreCase))
{
linkPath = Path.GetFileName(item.EvaluatedInclude);
item.SetMetadataValue(ProjectFileConstants.Link, linkPath);
}
}
HierarchyNode currentParent = GetItemParentNode(item, parentNodeCache);
return AddFileNodeToNode(item, currentParent);
}