• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Utilities.TaskItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Build.Utilities.TaskItem的典型用法代码示例。如果您正苦于以下问题:C# TaskItem类的具体用法?C# TaskItem怎么用?C# TaskItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TaskItem类属于Microsoft.Build.Utilities命名空间,在下文中一共展示了TaskItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:35,代码来源:AssignTargetPath.cs


示例2: Init

		public void Init()
		{
			mockCompiler = new MockPythonCompiler();
			compilerTask = new PythonCompilerTask(mockCompiler);
			sourceTaskItem = new TaskItem("test.py");
			compilerTask.Sources = new ITaskItem[] {sourceTaskItem};
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:7,代码来源:DifferentTargetTypesTestFixture.cs


示例3: SetMetaData

		private void SetMetaData(TaskItem item, string data, bool set)
		{
			if (set)
			{
				item.SetMetadata(TemplateFile.MetadataValueTag, data);
			}
		}
开发者ID:464884492,项目名称:msbuildtasks,代码行数:7,代码来源:TemplateFileTest.cs


示例4: NullITaskItem

        public void NullITaskItem()
        {
            ITaskItem item = null;
            TaskItem taskItem = new TaskItem(item);

            // no NullReferenceException
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:7,代码来源:TaskItem_Tests.cs


示例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;
 }
开发者ID:karajas,项目名称:buildtools,代码行数:7,代码来源:CreateTrimDependencyGroupsTests.cs


示例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;
        }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:29,代码来源:GetNugetPackageBasePath.cs


示例7: GetSourceFolder

        private static ITaskItem[] GetSourceFolder(string folder)
        {
            var folderItem = new TaskItem(folder);
            folderItem.SetMetadata("Test-name", "Test-Content");

            return new ITaskItem[] { folderItem };
        }
开发者ID:uluhonolulu,项目名称:Emkay.S3,代码行数:7,代码来源:PublishFolderWithHeadersTests.cs


示例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());
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:25,代码来源:CommandLineBuilderExtension_Tests.cs


示例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));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:CreateItem.cs


示例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);
        }
开发者ID:ericschultz,项目名称:ILRepackTask,代码行数:27,代码来源:Tests.cs


示例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));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:29,代码来源:InstalledSDKResolverFixture.cs


示例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;
        }
开发者ID:nikson,项目名称:msbuild,代码行数:35,代码来源:GetAssemblyIdentity.cs


示例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;
        }
开发者ID:NN---,项目名称:nuproj,代码行数:30,代码来源:ReadPackagesConfig.cs


示例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;
		}
开发者ID:wanglehui,项目名称:mono-addins,代码行数:35,代码来源:ResolveAddinReferences.cs


示例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);
        }
开发者ID:kovalikp,项目名称:nuproj,代码行数:30,代码来源:NuGetPack.cs


示例16: Execute

		public override bool Execute ()
		{
			assemblies = new ITaskItem [assembly_files.Length];

			for (int i = 0; i < assemblies.Length; i++) {
				string file = assembly_files [i].ItemSpec;
				AssemblyName an = AssemblyName.GetAssemblyName (file);
				TaskItem item = new TaskItem (an.FullName);

				item.SetMetadata ("Version", an.Version.ToString ());

				byte[] pk = an.GetPublicKeyToken ();
				string pkStr = pk != null? ByteArrayToString (pk) : "null";
				item.SetMetadata ("PublicKeyToken", pkStr);

				CultureInfo culture = an.CultureInfo;
				if (culture != null) {
					string cn;
					if (culture.LCID == CultureInfo.InvariantCulture.LCID)
						cn = "neutral";
					else
						cn = culture.Name;
					item.SetMetadata ("Culture", cn);
				}

				assemblies[i] = item;
			}

			return true;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:30,代码来源:GetAssemblyIdentity.cs


示例17: Execute

 public override bool Execute()
 {
     if (string.IsNullOrEmpty(SourceDirectory))
     {
         Log.LogError("Argument SourceDirectory is missing.");
         return false;
     }
     if (string.IsNullOrEmpty(StartAppPath))
     {
         Log.LogError("Argument StartAppPath is missing.");
         return false;
     }
     if (string.IsNullOrEmpty(UniqueSourceDirectoryPath))
     {
         Log.LogError("Argument UniqueSourceDirectoryPath is missing.");
         return false;
     }
     var orderer = new AppOrderer();
     var list = orderer.GetAppBuildOrder(SourceDirectory, StartAppPath, UniqueSourceDirectoryPath, Log);
     var returnList = new List<ITaskItem>();
     foreach (string app in list)
     {
         ITaskItem item = new TaskItem(app);
         item.SetMetadata("AppPath", app);
         returnList.Add(item);
     }
     AppList = returnList.ToArray();
     return true;
 }
开发者ID:nickvane,项目名称:AionMsBuildTasks,代码行数:29,代码来源:AppBuildOrderTask.cs


示例18: AddCommandLineCommands

		protected internal override void AddCommandLineCommands (
						CommandLineBuilderExtension commandLine)
		{
			if (Sources.Length == 0)
				return;

			foreach (ITaskItem item in Sources)
				commandLine.AppendSwitchIfNotNull ("--complist=", item.ItemSpec);

			commandLine.AppendSwitchIfNotNull ("--target=", LicenseTarget);

			if (ReferencedAssemblies != null)
				foreach (ITaskItem reference in ReferencedAssemblies)
					commandLine.AppendSwitchIfNotNull ("--load=", reference.ItemSpec);

			string outdir;
			if (Bag ["OutputDirectory"] != null)
				outdir = OutputDirectory;
			else
				outdir = ".";

			commandLine.AppendSwitchIfNotNull ("--outdir=", outdir);

			if (Bag ["NoLogo"] != null && NoLogo)
				commandLine.AppendSwitch ("--nologo");

			OutputLicense = new TaskItem (Path.Combine (OutputDirectory, LicenseTarget.ItemSpec + ".licenses"));
		}
开发者ID:Profit0004,项目名称:mono,代码行数:28,代码来源:LC.cs


示例19: Build

        public void Build()
        {
            RegexCompiler task = new RegexCompiler();
            task.BuildEngine = new MockBuild();
            task.OutputDirectory = TaskUtility.TestDirectory;
            task.AssemblyName = "MSBuild.Community.RegularExpressions.dll";
            task.AssemblyTitle = "MSBuild.Community.RegularExpressions";
            task.AssemblyDescription = "MSBuild Community Tasks Regular Expressions";
            task.AssemblyCompany = "MSBuildTasks";
            task.AssemblyProduct = "MSBuildTasks";
            task.AssemblyCopyright = "Copyright (c) MSBuildTasks 2008";
            task.AssemblyVersion = "1.0.0.0";
            task.AssemblyFileVersion = "1.0.0.0";
            task.AssemblyInformationalVersion = "1.0.0.0";
            task.AssemblyKeyFile = @"..\..\..\MSBuild.Community.Tasks\MSBuild.Community.Tasks.snk";

            List<ITaskItem> expressions = new List<ITaskItem>();

            TaskItem item1 = new TaskItem("TextRegex");
            item1.SetMetadata("Pattern", @"\G[^<]+");
            item1.SetMetadata("Options", "RegexOptions.Singleline | RegexOptions.Multiline");
            item1.SetMetadata("IsPublic", "true");

            TaskItem item2 = new TaskItem("CommentRegex");
            item2.SetMetadata("Pattern", @"\G<%--(([^-]*)-)*?-%>");
            item2.SetMetadata("Options", "RegexOptions.Singleline | RegexOptions.Multiline");
            item2.SetMetadata("IsPublic", "true");

            task.RegularExpressions = new ITaskItem[] {item1, item2};

            bool result = task.Execute();
            Assert.IsTrue(result);
        }
开发者ID:trippleflux,项目名称:jezatools,代码行数:33,代码来源:RegexCompilerTest.cs


示例20: Execute

		public override bool Execute() {
			var inputsGroupedByConfigFile = new Dictionary<string, List<WorkItem>>();
		
			OutputFiles = new ITaskItem[InputFiles.Length];
			for (int i = 0; i < InputFiles.Length; i++) {
				string infileLocal = InputFiles[i].ItemSpec;
				OutputFiles[i] = new TaskItem(Path.ChangeExtension(infileLocal, ExecutablesCommon.GeneratedFileExtension));
				string infile     = Path.GetFullPath(infileLocal);
				string outfile    = Path.ChangeExtension(infile, ExecutablesCommon.GeneratedFileExtension);
				string configFile = ExecutablesCommon.FindConfigFilePath(infile) ?? "";
				List<WorkItem> l;
				if (!inputsGroupedByConfigFile.TryGetValue(configFile, out l))
					inputsGroupedByConfigFile[configFile] = l = new List<WorkItem>();
				l.Add(new WorkItem() { InFile = infile, OutFile = outfile, Namespace = FindNamespace(InputFiles[i]) });
			}

			bool success = true;
			foreach (var kvp in inputsGroupedByConfigFile) {
                ExecutablesCommon.ProcessWorkItemsInSeparateAppDomain(kvp.Key, kvp.Value, (item, ex) => {
                    if (ex is TemplateErrorException) {
						Log.LogError(null, null, null, item.InFile, 0, 0, 0, 0, ex.Message);
						success = false;
					}
					else {
						Log.LogErrorFromException(ex, true, true, item.InFile);
						success = false;
					}
                    return true;
                });
			}
			return success;
		}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:32,代码来源:SalgenTask.cs



注:本文中的Microsoft.Build.Utilities.TaskItem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Utilities.TaskLoggingHelper类代码示例发布时间:2022-05-26
下一篇:
C# Utilities.CommandLineBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap