本文整理汇总了C#中Microsoft.Build.Utilities.TaskItem类的典型用法代码示例。如果您正苦于以下问题:C# TaskItem类的具体用法?C# TaskItem怎么用?C# TaskItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaskItem类属于Microsoft.Build.Utilities命名空间,在下文中一共展示了TaskItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override bool Execute ()
{
if (files == null || files.Length == 0)
//nothing to do
return true;
assignedFiles = new ITaskItem [files.Length];
for (int i = 0; i < files.Length; i ++) {
string file = files [i].ItemSpec;
string afile = null;
//FIXME: Hack!
string normalized_root = Path.GetFullPath (rootFolder);
// cur dir should already be set to
// the project dir
file = Path.GetFullPath (file);
if (file.StartsWith (normalized_root)) {
afile = Path.GetFullPath (file).Substring (
normalized_root.Length);
// skip over "root/"
if (afile [0] == '\\' ||
afile [0] == '/')
afile = afile.Substring (1);
} else {
afile = Path.GetFileName (file);
}
assignedFiles [i] = new TaskItem (files [i]);
assignedFiles [i].SetMetadata ("TargetPath", afile);
}
return true;
}
示例2: Init
public void Init()
{
mockCompiler = new MockPythonCompiler();
compilerTask = new PythonCompilerTask(mockCompiler);
sourceTaskItem = new TaskItem("test.py");
compilerTask.Sources = new ITaskItem[] {sourceTaskItem};
}
示例3: SetMetaData
private void SetMetaData(TaskItem item, string data, bool set)
{
if (set)
{
item.SetMetadata(TemplateFile.MetadataValueTag, data);
}
}
示例4: NullITaskItem
public void NullITaskItem()
{
ITaskItem item = null;
TaskItem taskItem = new TaskItem(item);
// no NullReferenceException
}
示例5: CreateFileItem
public static ITaskItem CreateFileItem(string sourcePath, string targetPath, string targetFramework)
{
TaskItem item = new TaskItem(sourcePath);
item.SetMetadata("TargetPath", targetPath);
item.SetMetadata("TargetFramework", targetFramework);
return item;
}
示例6: Execute
public override bool Execute()
{
Log.LogMessage (MessageImportance.Low, "Task GetNugetPackageBasePath");
Log.LogMessage (MessageImportance.Low, "\tPackageName : {0}", PackageName);
Log.LogMessage (MessageImportance.Low, "\tPackageConfigFiles : ");
foreach (ITaskItem file in PackageConfigFiles) {
Log.LogMessage (MessageImportance.Low, "\t\t{0}", file.ItemSpec);
}
Version latest = null;
foreach (string file in PackageConfigFiles.Select (x => Path.GetFullPath (x.ItemSpec)).Distinct ().OrderBy (x => x)) {
if (!File.Exists (file)) {
Log.LogWarning ("\tPackages config file {0} not found", file);
continue;
}
Version tmp = GetPackageVersion (file);
if (latest != null && latest >= tmp)
continue;
latest = tmp;
}
if (latest == null)
Log.LogError ("NuGet Package '{0}' not found", PackageName);
else
BasePath = new TaskItem (Path.Combine ("packages", $"{PackageName}.{latest}"));
Log.LogMessage (MessageImportance.Low, $"BasePath == {BasePath}");
return !Log.HasLoggedErrors;
}
示例7: GetSourceFolder
private static ITaskItem[] GetSourceFolder(string folder)
{
var folderItem = new TaskItem(folder);
folderItem.SetMetadata("Test-name", "Test-Content");
return new ITaskItem[] { folderItem };
}
示例8: AppendItemWithMissingAttribute
public void AppendItemWithMissingAttribute()
{
// Construct the task items.
TaskItem i = new TaskItem();
i.ItemSpec = "MySoundEffect.wav";
i.SetMetadata("Name", "Kenny");
i.SetMetadata("Access", "Private");
TaskItem j = new TaskItem();
j.ItemSpec = "MySplashScreen.bmp";
j.SetMetadata("Name", "Cartman");
j.SetMetadata("HintPath", @"c:\foo");
j.SetMetadata("Access", "Public");
CommandLineBuilderExtension c = new CommandLineBuilderExtension();
c.AppendSwitchIfNotNull
(
"/myswitch:",
new ITaskItem[] { i, j },
new string[] { "Name", "HintPath", "Access" },
null
);
Assert.Equal(@"/myswitch:MySoundEffect.wav,Kenny /myswitch:MySplashScreen.bmp,Cartman,c:\foo,Public", c.ToString());
}
示例9: ExpandWildcards
private static ITaskItem[] ExpandWildcards(ITaskItem[] expand)
{
if (expand == null)
{
return null;
}
ArrayList list = new ArrayList();
foreach (ITaskItem item in expand)
{
if (Microsoft.Build.Shared.FileMatcher.HasWildcards(item.ItemSpec))
{
foreach (string str in Microsoft.Build.Shared.FileMatcher.GetFiles(null, item.ItemSpec))
{
TaskItem item2 = new TaskItem(item) {
ItemSpec = str
};
Microsoft.Build.Shared.FileMatcher.Result result = Microsoft.Build.Shared.FileMatcher.FileMatch(item.ItemSpec, str);
if ((result.isLegalFileSpec && result.isMatch) && ((result.wildcardDirectoryPart != null) && (result.wildcardDirectoryPart.Length > 0)))
{
item2.SetMetadata("RecursiveDir", result.wildcardDirectoryPart);
}
list.Add(item2);
}
}
else
{
list.Add(item);
}
}
return (ITaskItem[]) list.ToArray(typeof(ITaskItem));
}
示例10: BasicTestCreate
public void BasicTestCreate()
{
var basicSampleTaskItem = new TaskItem("BasicSample");
var cSharpTaskItem = new TaskItem("Microsoft.CSharp");
var serviceTaskItem = new TaskItem(
"Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
var task = new FindAssembliesInOutputDirTask(_fileSystem)
{
InputAssemblies = new ITaskItem[]
{
basicSampleTaskItem,
cSharpTaskItem,
serviceTaskItem
},
OutputDir = new[]
{
@"C:\"
}
};
Assert.True(task.Execute());
var outputs = task.AssembliesInOutputDir;
Assert.Contains(basicSampleTaskItem, outputs);
Assert.Contains(serviceTaskItem, outputs);
Assert.DoesNotContain(cSharpTaskItem, outputs);
}
示例11: ResolveSDKFromRefereneAssemblyLocation
private static void ResolveSDKFromRefereneAssemblyLocation(string referenceName, string expectedPath)
{
// Create the engine.
MockEngine engine = new MockEngine();
TaskItem taskItem = new TaskItem(referenceName);
taskItem.SetMetadata("SDKName", "FakeSDK, Version=1.0");
TaskItem resolvedSDK = new TaskItem(@"C:\FakeSDK");
resolvedSDK.SetMetadata("SDKName", "FakeSDK, Version=1.0");
resolvedSDK.SetMetadata("TargetedSDKConfiguration", "Debug");
resolvedSDK.SetMetadata("TargetedSDKArchitecture", "X86");
TaskItem[] assemblies = new TaskItem[] { taskItem };
// Now, pass feed resolved primary references into ResolveAssemblyReference.
ResolveAssemblyReference t = new ResolveAssemblyReference();
t.BuildEngine = engine;
t.Assemblies = assemblies;
t.ResolvedSDKReferences = new ITaskItem[] { resolvedSDK };
t.SearchPaths = new String[] { @"C:\SomeOtherPlace" };
bool succeeded = Execute(t);
Assert.True(succeeded);
Assert.Equal(1, t.ResolvedFiles.Length);
Assert.Equal(0, engine.Errors);
Assert.Equal(0, engine.Warnings);
Assert.True(t.ResolvedFiles[0].ItemSpec.Equals(expectedPath, StringComparison.OrdinalIgnoreCase));
}
示例12: Execute
public override bool Execute()
{
ArrayList list = new ArrayList();
foreach (ITaskItem item in AssemblyFiles)
{
AssemblyName an;
try
{
an = AssemblyName.GetAssemblyName(item.ItemSpec);
}
catch (BadImageFormatException e)
{
Log.LogErrorWithCodeFromResources("GetAssemblyIdentity.CouldNotGetAssemblyName", item.ItemSpec, e.Message);
continue;
}
catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e))
{
Log.LogErrorWithCodeFromResources("GetAssemblyIdentity.CouldNotGetAssemblyName", item.ItemSpec, e.Message);
continue;
}
ITaskItem newItem = new TaskItem(an.FullName);
newItem.SetMetadata("Name", an.Name);
if (an.Version != null)
newItem.SetMetadata("Version", an.Version.ToString());
if (an.GetPublicKeyToken() != null)
newItem.SetMetadata("PublicKeyToken", ByteArrayToHex(an.GetPublicKeyToken()));
if (an.CultureInfo != null)
newItem.SetMetadata("Culture", an.CultureInfo.ToString());
item.CopyMetadataTo(newItem);
list.Add(newItem);
}
Assemblies = (ITaskItem[])list.ToArray(typeof(ITaskItem));
return !Log.HasLoggedErrors;
}
示例13: 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;
}
示例14: Execute
public override bool Execute ()
{
if (string.IsNullOrEmpty (extensionDomain)) {
Log.LogError ("ExtensionDomain item not found");
return false;
}
if (addinReferences == null) {
return true;
}
Application app = SetupService.GetExtensibleApplication (extensionDomain);
if (app == null) {
Log.LogError ("Extension domain '{0}' not found", extensionDomain);
return false;
}
foreach (ITaskItem item in addinReferences) {
string addinId = item.ItemSpec.Replace (':',',');
Addin addin = app.Registry.GetAddin (addinId);
if (addin == null) {
Log.LogError ("Add-in '{0}' not found", addinId);
return false;
}
if (addin.Description == null) {
Log.LogError ("Add-in '{0}' could not be loaded", addinId);
return false;
}
foreach (string asm in addin.Description.MainModule.Assemblies) {
string file = Path.Combine (addin.Description.BasePath, asm);
TaskItem ti = new TaskItem (file);
references.Add (ti);
}
}
return true;
}
示例15: LogEventsFromTextOutput
protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance)
{
if (singleLine.StartsWith("Successfully created package"))
{
var outputPackage = singleLine.Split('\'').Skip(1).First();
var outputPackageItem = new TaskItem(outputPackage);
if (outputPackage.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase))
{
OutputSymbolsPackage = new[] { outputPackageItem };
}
else
{
OutputPackage = new[] { outputPackageItem };
}
}
if (messageImportance == MessageImportance.High)
{
Log.LogError(singleLine);
return;
}
if (singleLine.StartsWith("Issue:") || singleLine.StartsWith("Description:") || singleLine.StartsWith("Solution:"))
{
Log.LogWarning(singleLine);
return;
}
base.LogEventsFromTextOutput(singleLine, messageImportance);
}