本文整理汇总了C#中ITaskItem.CopyMetadataTo方法的典型用法代码示例。如果您正苦于以下问题:C# ITaskItem.CopyMetadataTo方法的具体用法?C# ITaskItem.CopyMetadataTo怎么用?C# ITaskItem.CopyMetadataTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITaskItem
的用法示例。
在下文中一共展示了ITaskItem.CopyMetadataTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertPackageElement
protected ITaskItem ConvertPackageElement(ITaskItem project, PackageReference packageReference)
{
var id = packageReference.Id;
var version = packageReference.Version;
var targetFramework = packageReference.TargetFramework;
var isDevelopmentDependency = packageReference.IsDevelopmentDependency;
var requireReinstallation = packageReference.RequireReinstallation;
var versionConstraint = packageReference.VersionConstraint;
var item = new TaskItem(id);
project.CopyMetadataTo(item);
var packageDirectoryPath = GetPackageDirectoryPath(project.GetMetadata("FullPath"), id, version);
item.SetMetadata("PackageDirectoryPath", packageDirectoryPath);
item.SetMetadata("ProjectPath", project.GetMetadata("FullPath"));
item.SetMetadata("IsDevelopmentDependency", isDevelopmentDependency.ToString());
item.SetMetadata("RequireReinstallation", requireReinstallation.ToString());
if (version != null)
item.SetMetadata(Metadata.Version, version.ToString());
if (targetFramework != null)
item.SetMetadata(Metadata.TargetFramework, targetFramework.GetShortFrameworkName());
if (versionConstraint != null)
item.SetMetadata("VersionConstraint", versionConstraint.ToString());
return item;
}
示例2: ResolveProject
internal bool ResolveProject(ITaskItem projectRef, out ITaskItem resolvedPath)
{
string projectItem = base.GetProjectItem(projectRef);
if (projectItem != null)
{
resolvedPath = new TaskItem(projectItem);
projectRef.CopyMetadataTo(resolvedPath);
return true;
}
resolvedPath = null;
return false;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:ResolveNonMSBuildProjectOutput.cs
示例3: TaskItem
public TaskItem(ITaskItem sourceItem)
{
ErrorUtilities.VerifyThrowArgumentNull(sourceItem, "sourceItem");
ITaskItem2 item = sourceItem as ITaskItem2;
if (item == null)
{
this.itemSpec = sourceItem.ItemSpec;
}
else
{
this.itemSpec = item.EvaluatedIncludeEscaped;
}
sourceItem.CopyMetadataTo(this);
}
示例4: CreateFileItem
private static ITaskItem CreateFileItem(ITaskItem item, string group, string targetPath, string includeHash, bool isDataFile)
{
ITaskItem destinationItem = new TaskItem(item.ItemSpec);
item.CopyMetadataTo(destinationItem);
if (string.IsNullOrEmpty(targetPath))
{
targetPath = GetItemTargetPath(destinationItem);
}
destinationItem.SetMetadata("TargetPath", targetPath);
if (!string.IsNullOrEmpty(group) && !isDataFile)
{
destinationItem.SetMetadata("Group", group);
}
if (!string.IsNullOrEmpty(includeHash))
{
destinationItem.SetMetadata("IncludeHash", includeHash);
}
destinationItem.SetMetadata("IsDataFile", isDataFile.ToString().ToLowerInvariant());
return destinationItem;
}
示例5: CreateAssemblyItem
private static ITaskItem CreateAssemblyItem(ITaskItem item, string group, string targetPath, string includeHash)
{
ITaskItem destinationItem = new TaskItem(item.ItemSpec);
item.CopyMetadataTo(destinationItem);
destinationItem.SetMetadata("DependencyType", "Install");
if (string.IsNullOrEmpty(targetPath))
{
targetPath = GetItemTargetPath(destinationItem);
}
destinationItem.SetMetadata("TargetPath", targetPath);
if (!string.IsNullOrEmpty(group))
{
destinationItem.SetMetadata("Group", group);
}
if (!string.IsNullOrEmpty(includeHash))
{
destinationItem.SetMetadata("IncludeHash", includeHash);
}
return destinationItem;
}
示例6: TaskItemWithNewExtension
private static ITaskItem TaskItemWithNewExtension(ITaskItem item, string extension) {
var newItem = new TaskItem(Path.ChangeExtension(item.ItemSpec, extension));
item.CopyMetadataTo(newItem);
return newItem;
}
示例7: CreatePrerequisiteItem
private static ITaskItem CreatePrerequisiteItem(ITaskItem item)
{
ITaskItem destinationItem = new TaskItem(item.ItemSpec);
item.CopyMetadataTo(destinationItem);
destinationItem.SetMetadata("DependencyType", "Prerequisite");
return destinationItem;
}
示例8: GetOutputEntryPoint
private ITaskItem GetOutputEntryPoint(ITaskItem entryPoint, PublishInfo[] manifestEntryPointList)
{
if (entryPoint == null)
{
return null;
}
TaskItem destinationItem = new TaskItem(entryPoint.ItemSpec);
entryPoint.CopyMetadataTo(destinationItem);
string metadata = entryPoint.GetMetadata("TargetPath");
if (!string.IsNullOrEmpty(metadata))
{
for (int i = 0; i < manifestEntryPointList.Length; i++)
{
if (string.Equals(metadata, manifestEntryPointList[i].key, StringComparison.OrdinalIgnoreCase))
{
if (!string.IsNullOrEmpty(manifestEntryPointList[i].includeHash))
{
if (((manifestEntryPointList[i].state != PublishState.Exclude) && string.Equals(manifestEntryPointList[i].includeHash, "false", StringComparison.OrdinalIgnoreCase)) && this.SigningManifests)
{
this.canPublish = false;
}
destinationItem.SetMetadata("IncludeHash", manifestEntryPointList[i].includeHash);
}
return destinationItem;
}
}
}
return destinationItem;
}
示例9: DoDownload
private void DoDownload(Request documentsRequest, ITaskItem document, ITaskItem download)
{
string sourceFile = document.ItemSpec;
string targetFile = download.ItemSpec;
string targetDirectory = Path.GetDirectoryName(targetFile);
Log.LogMessage(MessageImportance.High,"Downloading \"{0}\"", document.RequireTitle());
Log.LogMessage(MessageImportance.Normal, "To \"{0}\"", targetDirectory);
download.RequireParentDirectory(Log);
if (!File.Exists(sourceFile))
{
throw new FileNotFoundException("Cannot find", sourceFile);
}
ResourceType resourceType = document.RequireResourceType();
switch (resourceType)
{
case ResourceType.file:
DoFileDownload(documentsRequest, document, targetFile);
break;
case ResourceType.document:
DoDocumentDownload(documentsRequest, document, targetFile);
break;
default:
throw new NotImplementedException(string.Format("Resource Type '{0}' is unsupported", resourceType));
}
DateTime updated = document.GetTimestamp();
File.SetLastWriteTime(download.ItemSpec, updated);
document.CopyMetadataTo(download);
}
示例10: ExtractFromManifest
/// <summary>
/// Helper manifest resolution method. Cracks the manifest and extracts the different elements from it.
/// </summary>
internal bool ExtractFromManifest(ITaskItem taskItem, string path, Hashtable containingReferenceFilesTable, Hashtable containedPrerequisiteAssembliesTable, Hashtable containedComComponentsTable, Hashtable containedTypeLibrariesTable, Hashtable containedLooseTlbFilesTable, Hashtable containedLooseEtcFilesTable)
{
Log.LogMessageFromResources(MessageImportance.Low, "ResolveNativeReference.Comment", path);
Manifest manifest = null;
try
{
manifest = ManifestReader.ReadManifest(path, false);
}
catch (System.Xml.XmlException ex)
{
Log.LogErrorWithCodeFromResources("GenerateManifest.ReadInputManifestFailed", path, ex.Message);
return false;
}
if (manifest != null)
{
manifest.TreatUnfoundNativeAssembliesAsPrerequisites = true;
manifest.ReadOnly = true; // only reading a manifest, set flag so we get GenerateManifest.ResolveFailedInReadOnlyMode instead of GenerateManifest.ResolveFailedInReadWriteMode messages
manifest.ResolveFiles();
if (!manifest.OutputMessages.LogTaskMessages(this))
return false;
ApplicationManifest applicationManifest = manifest as ApplicationManifest;
bool isClickOnceApp = applicationManifest != null && applicationManifest.IsClickOnceManifest;
// ClickOnce application manifest should not be added as native reference, but we should open and process it.
if (containingReferenceFilesTable.ContainsKey(path) == false && !isClickOnceApp)
{
ITaskItem itemNativeReferenceFile = new TaskItem();
itemNativeReferenceFile.ItemSpec = path;
if (manifest.AssemblyIdentity.Name != null)
itemNativeReferenceFile.SetMetadata(ItemMetadataNames.fusionName, manifest.AssemblyIdentity.Name);
if (taskItem != null)
taskItem.CopyMetadataTo(itemNativeReferenceFile);
containingReferenceFilesTable.Add(path, itemNativeReferenceFile);
}
if (manifest.AssemblyReferences != null)
{
foreach (AssemblyReference assemblyref in manifest.AssemblyReferences)
{
if (assemblyref.IsVirtual)
{
//It is a CLR virtual reference, not a real reference.
continue;
}
if (!assemblyref.IsPrerequisite)
{
// recurse and call ExtractFromManifest for this assembly--if it has a manifest it will be cracked.
ExtractFromManifest(null, assemblyref.ResolvedPath, containingReferenceFilesTable, containedPrerequisiteAssembliesTable, containedComComponentsTable, containedTypeLibrariesTable, containedLooseTlbFilesTable, containedLooseEtcFilesTable);
}
else
{
string id = assemblyref.AssemblyIdentity.GetFullName(AssemblyIdentity.FullNameFlags.All);
// add the assembly to the prerequisites list, if it's not already there
if (containedPrerequisiteAssembliesTable.ContainsKey(id) == false)
{
ITaskItem item = new TaskItem();
item.ItemSpec = id;
item.SetMetadata("DependencyType", "Prerequisite");
containedPrerequisiteAssembliesTable.Add(id, item);
}
}
}
}
if (manifest.FileReferences != null)
{
foreach (FileReference fileref in manifest.FileReferences)
{
if (fileref.ResolvedPath == null)
continue;
// add the loose file to the outputs list, if it's not already there
if (containedLooseEtcFilesTable.ContainsKey(fileref.ResolvedPath) == false)
{
ITaskItem itemLooseEtcFile = new TaskItem();
itemLooseEtcFile.ItemSpec = fileref.ResolvedPath;
// The ParentFile attribute (visible thru Project Outputs) relates the loose
// file to the parent assembly of which it is a part. This is important so we can
// group those files together with their parent assembly in the deployment tool
// (i.e. ClickOnce application files dialog).
itemLooseEtcFile.SetMetadata(ItemMetadataNames.parentFile, Path.GetFileName(path));
containedLooseEtcFilesTable.Add(fileref.ResolvedPath, itemLooseEtcFile);
}
if (fileref.ComClasses != null)
{
foreach (ComClass comclass in fileref.ComClasses)
{
// add the comclass to the outputs list, if it's not already there
if (containedComComponentsTable.ContainsKey(comclass.ClsId) == false)
{
ITaskItem itemComClass = new TaskItem();
itemComClass.ItemSpec = comclass.ClsId;
//.........这里部分代码省略.........
示例11: GetOutputEntryPoint
private ITaskItem GetOutputEntryPoint(ITaskItem entryPoint, PublishInfo[] manifestEntryPointList)
{
if (entryPoint == null)
{
return null;
}
TaskItem outputEntryPoint = new TaskItem(entryPoint.ItemSpec);
entryPoint.CopyMetadataTo(outputEntryPoint);
string targetPath = entryPoint.GetMetadata("TargetPath");
if (!string.IsNullOrEmpty(targetPath))
{
for (int i = 0; i < manifestEntryPointList.Length; i++)
{
if (String.Equals(targetPath, manifestEntryPointList[i].key, StringComparison.OrdinalIgnoreCase))
{
if (!string.IsNullOrEmpty(manifestEntryPointList[i].includeHash))
{
if (manifestEntryPointList[i].state != PublishState.Exclude &&
string.Equals(manifestEntryPointList[i].includeHash, "false", StringComparison.OrdinalIgnoreCase) &&
SigningManifests == true)
_canPublish = false;
outputEntryPoint.SetMetadata("IncludeHash", manifestEntryPointList[i].includeHash);
}
return outputEntryPoint;
}
}
}
return outputEntryPoint;
}
示例12: CreateFileItem
// Creates an output item for a file, with optional Group and IsData attributes.
private static ITaskItem CreateFileItem(ITaskItem item, string group, string targetPath, string includeHash, bool isDataFile)
{
ITaskItem outputItem = new TaskItem(item.ItemSpec);
item.CopyMetadataTo(outputItem);
if (String.IsNullOrEmpty(targetPath))
targetPath = GetItemTargetPath(outputItem);
outputItem.SetMetadata(ItemMetadataNames.targetPath, targetPath);
if (!String.IsNullOrEmpty(group) && !isDataFile)
outputItem.SetMetadata("Group", group);
if (!String.IsNullOrEmpty(includeHash))
outputItem.SetMetadata("IncludeHash", includeHash);
outputItem.SetMetadata("IsDataFile", isDataFile.ToString().ToLowerInvariant());
return outputItem;
}
示例13: CreateAssemblyItem
// Creates an output item for a an assembly, with optional Group attribute.
private static ITaskItem CreateAssemblyItem(ITaskItem item, string group, string targetPath, string includeHash)
{
ITaskItem outputItem = new TaskItem(item.ItemSpec);
item.CopyMetadataTo(outputItem);
outputItem.SetMetadata("DependencyType", "Install");
if (String.IsNullOrEmpty(targetPath))
targetPath = GetItemTargetPath(outputItem);
outputItem.SetMetadata(ItemMetadataNames.targetPath, targetPath);
if (!String.IsNullOrEmpty(group))
outputItem.SetMetadata("Group", group);
if (!String.IsNullOrEmpty(includeHash))
outputItem.SetMetadata("IncludeHash", includeHash);
return outputItem;
}
示例14: ExtractFromManifest
internal bool ExtractFromManifest(ITaskItem taskItem, string path, Hashtable containingReferenceFilesTable, Hashtable containedPrerequisiteAssembliesTable, Hashtable containedComComponentsTable, Hashtable containedTypeLibrariesTable, Hashtable containedLooseTlbFilesTable, Hashtable containedLooseEtcFilesTable)
{
base.Log.LogMessageFromResources(MessageImportance.Low, "ResolveNativeReference.Comment", new object[] { path });
Manifest manifest = null;
try
{
manifest = ManifestReader.ReadManifest(path, false);
}
catch (XmlException exception)
{
base.Log.LogErrorWithCodeFromResources("GenerateManifest.ReadInputManifestFailed", new object[] { path, exception.Message });
return false;
}
if (manifest != null)
{
manifest.TreatUnfoundNativeAssembliesAsPrerequisites = true;
manifest.ReadOnly = true;
manifest.ResolveFiles();
if (!manifest.OutputMessages.LogTaskMessages(this))
{
return false;
}
ApplicationManifest manifest2 = manifest as ApplicationManifest;
bool flag = (manifest2 != null) && manifest2.IsClickOnceManifest;
if (!containingReferenceFilesTable.ContainsKey(path) && !flag)
{
ITaskItem destinationItem = new TaskItem {
ItemSpec = path
};
if (manifest.AssemblyIdentity.Name != null)
{
destinationItem.SetMetadata("FusionName", manifest.AssemblyIdentity.Name);
}
if (taskItem != null)
{
taskItem.CopyMetadataTo(destinationItem);
}
containingReferenceFilesTable.Add(path, destinationItem);
}
if (manifest.AssemblyReferences != null)
{
foreach (AssemblyReference reference in manifest.AssemblyReferences)
{
if (!reference.IsVirtual)
{
if (!reference.IsPrerequisite)
{
this.ExtractFromManifest(null, reference.ResolvedPath, containingReferenceFilesTable, containedPrerequisiteAssembliesTable, containedComComponentsTable, containedTypeLibrariesTable, containedLooseTlbFilesTable, containedLooseEtcFilesTable);
}
else
{
string fullName = reference.AssemblyIdentity.GetFullName(AssemblyIdentity.FullNameFlags.All);
if (!containedPrerequisiteAssembliesTable.ContainsKey(fullName))
{
ITaskItem item2 = new TaskItem {
ItemSpec = fullName
};
item2.SetMetadata("DependencyType", "Prerequisite");
containedPrerequisiteAssembliesTable.Add(fullName, item2);
}
}
}
}
}
if (manifest.FileReferences != null)
{
foreach (FileReference reference2 in manifest.FileReferences)
{
if (reference2.ResolvedPath != null)
{
if (!containedLooseEtcFilesTable.ContainsKey(reference2.ResolvedPath))
{
ITaskItem item3 = new TaskItem {
ItemSpec = reference2.ResolvedPath
};
item3.SetMetadata("ParentFile", Path.GetFileName(path));
containedLooseEtcFilesTable.Add(reference2.ResolvedPath, item3);
}
if (reference2.ComClasses != null)
{
foreach (ComClass class2 in reference2.ComClasses)
{
if (!containedComComponentsTable.ContainsKey(class2.ClsId))
{
ITaskItem item4 = new TaskItem {
ItemSpec = class2.ClsId
};
containedComComponentsTable.Add(class2.ClsId, item4);
}
}
}
if (reference2.TypeLibs != null)
{
foreach (TypeLib lib in reference2.TypeLibs)
{
if (!containedTypeLibrariesTable.ContainsKey(lib.TlbId))
{
ITaskItem item5 = new TaskItem {
ItemSpec = lib.TlbId
};
//.........这里部分代码省略.........
示例15: BuildContent
private TaskItem BuildContent(ITaskItem folder, Document document, PathMapping folderMapping)
{
PathMapping documentPath = new PathMapping(folderMapping, new TaskItem().FillMetadata(document));
string targetFile = documentPath.MappedPath;
TaskItem content = new TaskItem(targetFile);
folder.CopyMetadataTo(content, FolderMetadataPrefix ?? "Folder");
content.FillMetadata(documentPath);
content.FillMetadata(document);
content.RequireParentDirectory(Log);
if (content.Exists())
{
DateTime updated = File.GetLastWriteTime(targetFile);
Log.LogMessage(MessageImportance.Normal, "Exists at \"{0}\"", targetFile);
if (updated != document.Updated)
{
Log.LogMessage(MessageImportance.Low, "Updated - Local: {0} Remote: {1}", updated, document.Updated);
}
else
{
Log.LogMessage(MessageImportance.Low, "Updated - {0}", document.Updated);
}
}
else
{
Log.LogMessage(MessageImportance.Normal, "Detected new document");
}
if (document.DocumentEntry != null &&
document.DocumentEntry.Content != null &&
document.DocumentEntry.Content.Src != null)
{
content.SetMetadata("ExportUri", document.DocumentEntry.Content.Src.ToString());
}
content.Save(Log, document.Updated);
return content;
}