当前位置: 首页>>代码示例>>C#>>正文


C# ITaskItem.GetMetadata方法代码示例

本文整理汇总了C#中ITaskItem.GetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# ITaskItem.GetMetadata方法的具体用法?C# ITaskItem.GetMetadata怎么用?C# ITaskItem.GetMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITaskItem的用法示例。


在下文中一共展示了ITaskItem.GetMetadata方法的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;
        }
开发者ID:NN---,项目名称:nuproj,代码行数:30,代码来源:ReadPackagesConfig.cs

示例2: GetLinkPath

		static string GetLinkPath (ITaskItem file, string path)
		{
			string link = file.GetMetadata ("Link");
			if (!string.IsNullOrEmpty (link)) {
				return link;
			}

			string projectDir;
			var definingProject = file.GetMetadata ("DefiningProjectFullPath");
			if (!string.IsNullOrEmpty (definingProject)) {
				projectDir = Path.GetDirectoryName (definingProject);
			} else {
				projectDir = Environment.CurrentDirectory;
			}

			projectDir = Path.GetFullPath (projectDir);
			if (projectDir [projectDir.Length - 1] != Path.DirectorySeparatorChar) {
				projectDir += Path.DirectorySeparatorChar;
			}

			if (path.StartsWith (projectDir, StringComparison.Ordinal)) {
				link = path.Substring (projectDir.Length);
			} else {
				link = Path.GetFileName (path);
			}

			return link;
		}
开发者ID:Therzok,项目名称:MonoDevelop.AddinMaker,代码行数:28,代码来源:CollectOutputFiles.cs

示例3: ValidationPattern

            public ValidationPattern(ITaskItem item, TaskLoggingHelper log)
            {
                string idRegex = item.GetMetadata("IdentityRegex");
                if (string.IsNullOrEmpty(idRegex))
                {
                    // Temporarily support reading the regex from the Include/ItemSpec for backwards compatibility
                    // when the IdentityRegex isn't specified. This can be removed once all consumers are using IdentityRegex.
                    idRegex = item.ItemSpec;
                }

                _idPattern = new Regex(idRegex);
                _expectedVersion = item.GetMetadata("ExpectedVersion");
                _expectedPrerelease = item.GetMetadata("ExpectedPrerelease");
                _log = log;

                if (string.IsNullOrWhiteSpace(_expectedVersion))
                {
                    if (string.IsNullOrWhiteSpace(_expectedPrerelease))
                    {
                        _log.LogError(
                            "Can't find ExpectedVersion or ExpectedPrerelease metadata on item {0}",
                            item.ItemSpec);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(_expectedPrerelease))
                {
                    _log.LogError(
                        "Both ExpectedVersion and ExpectedPrerelease metadata found on item {0}, but only one permitted",
                        item.ItemSpec);
                }
            }
开发者ID:dsgouda,项目名称:buildtools,代码行数:31,代码来源:ValidateProjectDependencyVersions.cs

示例4: FindNamespace

		private string FindNamespace(ITaskItem item) {
			string s = item.GetMetadata("CustomToolNamespace");
			if (!string.IsNullOrEmpty(s))
				return s;	// Easy - the namespace was set explicitly
			s = item.GetMetadata("Link");	// If the Link metadata is set, it defines the file as the project sees it.
			string dir = Path.GetDirectoryName(!string.IsNullOrEmpty(s) ? s : item.ItemSpec);

			string rootNamespaceWithDot = RootNamespace;
			if (!string.IsNullOrEmpty(rootNamespaceWithDot) && !rootNamespaceWithDot.EndsWith(".") && !string.IsNullOrEmpty(dir))
				rootNamespaceWithDot += ".";
			return rootNamespaceWithDot + dir;
		}
开发者ID:fiinix00,项目名称:Saltarelle,代码行数:12,代码来源:SalgenTask.cs

示例5: GetReplacings

 protected override IEnumerable<Replacing> GetReplacings(ITaskItem item, string text)
 {
     foreach (var repl in base.GetReplacings(item, text)) yield return repl;
     int i = 0;
     string n = i > 0 ? i.ToString() : "";
     string regex;
     while (!string.IsNullOrEmpty(regex = item.GetMetadata("Replacing"+n))) {
         int count;
         if (!int.TryParse(item.GetMetadata("ReplaceCount"+n) ?? "", out count)) count = -1;
         var options = ParseOptions(item.GetMetadata("ReplaceOptions"));
         yield return new Replacing { Expression = regex, Options = options, Count = count, Replacement = item.GetMetadata("Replacement"+n) };
         i++;
         n = i > 0 ? i.ToString() : "";
     }
 }
开发者ID:simonegli8,项目名称:msbuildtasks,代码行数:15,代码来源:CustomReplace.cs

示例6: GetProjectElement

 protected XmlElement GetProjectElement(ITaskItem projectRef)
 {
     string metadata = projectRef.GetMetadata("Project");
     XmlElement element = null;
     if (this.cachedProjectElements.TryGetValue(metadata, out element) && (element != null))
     {
         return element;
     }
     string key = projectRef.GetMetadata("FullPath");
     if (this.cachedProjectElementsByAbsolutePath.TryGetValue(key, out element) && (element != null))
     {
         return element;
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:ResolveProjectBase.cs

示例7: PackageFile

        public PackageFile( ITaskItem item )
        {
            FullPath = item.GetMetadata( "FullPath" );
            PathInProject = item.ItemSpec;

            var environmentData = item.GetMetadata( "Environment" );
            if( string.IsNullOrEmpty( environmentData ) )
                environmentData = "None";

            var isDashboardData = item.GetMetadata( "IsDashboard" );
            if( string.IsNullOrEmpty( isDashboardData ) )
                isDashboardData = "false";

            Environment = ( TargetEnvironment )Enum.Parse( typeof( TargetEnvironment ), environmentData, true );
            IsDashboard = bool.Parse( isDashboardData );
        }
开发者ID:Rantanen,项目名称:M-Files-SDK,代码行数:16,代码来源:PackageFile.cs

示例8: GetTarget

 static string GetTarget(ITaskItem x)
 {
     var target = x.GetMetadata("TargetPath");
     if (Path.GetFileName(x.ItemSpec) == Path.GetFileName(target))
         target = Path.GetDirectoryName(target);
     return target;
 }
开发者ID:modulexcite,项目名称:openwrap,代码行数:7,代码来源:PublishPackageContent.cs

示例9: ResolvePackage

        private IEnumerable<ITaskItem> ResolvePackage(ITaskItem package)
        {
            string id = package.ItemSpec;
            string version = package.GetMetadata("Version");

            Log.LogMessage(MessageImportance.Normal, "Resolving Package Reference {0} {1}...", id, version);

            // Initial version just searches a machine-level repository

            var localFs = new PhysicalFileSystem(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NuGet", "Lib"));
            var defaultResolver = new DefaultPackagePathResolver(localFs);
            var machineRepo = new LocalPackageRepository(defaultResolver, localFs);
            var buildRepo = new BuildPackageRepository();
            var remoteRepo = new DataServicePackageRepository(new Uri("https://nuget.org/api/v2"));
            var project = new BuildProjectSystem(ProjectDirectory, new FrameworkName(TargetFramework), CurrentReferences);
            var manager = new PackageManager(remoteRepo, defaultResolver, localFs, machineRepo);
            var projectManager = new ProjectManager(remoteRepo, defaultResolver, project, buildRepo);

            // Install the package
            var ver = new SemanticVersion(version);
            manager.PackageInstalling += manager_PackageInstalling;
            manager.InstallPackage(id, ver);
            projectManager.AddPackageReference(id, ver);

            return project.OutputReferences.Select(item =>
            {
                var name = AssemblyName.GetAssemblyName(item);
                return new TaskItem(name.FullName, new Dictionary<string, string>() {
                    {"HintPath", item },
                    {"Private", "true"}
                });
            });
        }
开发者ID:anurse,项目名称:NuGetBuild,代码行数:33,代码来源:ResolvePackageReference.cs

示例10: ComputeNeutralXlfName

        private string ComputeNeutralXlfName(ITaskItem neutralResouce)
        {
            var filename = neutralResouce.GetMetadata("Filename");
            var xlfRootPath = LocalizationUtils.ComputeXlfRootPath(neutralResouce);

            return Path.Combine(xlfRootPath, filename + ".xlf");
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:7,代码来源:ConvertToNeutralXlf.cs

示例11: Parse

        public string Parse(ITaskItem taskItem, bool fullOutputName, string outputExtension)
        {
            CommandLineBuilder builder = new CommandLineBuilder();

            foreach (string name in taskItem.MetadataNames)
            {
                string value = taskItem.GetMetadata(name);
                if (outputExtension != null && name == "OutputFile")
                {
                    value = Path.ChangeExtension(value, outputExtension);
                }
                if (fullOutputName && name == "ObjectFileName")
                {
                    if ((File.GetAttributes(value) & FileAttributes.Directory) != 0)
                    {
                        value = Path.Combine(value, Path.GetFileName(taskItem.ItemSpec));
                        value = Path.ChangeExtension(value, ".obj");
                    }
                }
                AppendArgumentForProperty(builder, name, value);
            }

            string result = builder.ToString();
            result = result.Replace('\\', '/'); // posix paths
            return result;
        }
开发者ID:udiavr,项目名称:nativeclient-sdk,代码行数:26,代码来源:XamlParser.cs

示例12: ComputeLocalizedResource

        private ITaskItem ComputeLocalizedResource(ITaskItem xlf)
        {
            var resxName = xlf.GetMetadata("FileName");
            var resxFileName = resxName + ".resx";
            var resxPath = Path.Combine(LocalizedResxRoot, resxFileName);

            var resxItem = new TaskItem(resxPath);
            resxItem.SetMetadata(NeutralResxMetadata, xlf.GetMetadata(NeutralResxMetadata));
            resxItem.SetMetadata(ParentXlfMetadata, xlf.ItemSpec);
            resxItem.SetMetadata(ComputedCultureCodeMetadata, xlf.GetMetadata(ComputedCultureCodeMetadata));
            resxItem.SetMetadata(LogicalNameMetadata, $"{AssemblyName}.{resxName}.resources");

            xlf.SetMetadata(ChildResxMetadata, resxPath);

            return resxItem;
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:16,代码来源:EmitLocalizedResources.cs

示例13: BuiltItem

        internal BuiltItem(string targetName, ITaskItem item)
        {
            TargetName = targetName;
            OutputPath = item.ItemSpec;

            foreach (var name in item.MetadataNames)
                Metadata.Add((string)name, item.GetMetadata((string)name));
        }
开发者ID:poizan42,项目名称:JSIL,代码行数:8,代码来源:SolutionBuilder.cs

示例14: PackageItem

        public PackageItem(ITaskItem item)
        {
            OriginalItem = item;
            SourcePath = item.GetMetadata("FullPath");
            SourceProject = GetMetadata("MSBuildSourceProjectFile");
            string value = GetMetadata("TargetFramework");
            if (!String.IsNullOrWhiteSpace(value))
            {
                TargetFramework = NuGetFramework.Parse(value);
            }
            TargetPath = item.GetMetadata(nameof(TargetPath));
            AdditionalProperties = GetMetadata(nameof(AdditionalProperties));
            UndefineProperties = GetMetadata(nameof(UndefineProperties));
            HarvestedFrom = GetMetadata(nameof(HarvestedFrom));
            Package = GetMetadata("PackageId");
            PackageVersion = GetMetadata("PackageVersion");
            IsDll = Path.GetExtension(SourcePath).Equals(".dll", StringComparison.OrdinalIgnoreCase);
            IsPlaceholder = NuGetAssetResolver.IsPlaceholder(SourcePath);
            IsRef = TargetPath.StartsWith("ref/", StringComparison.OrdinalIgnoreCase);

            // determine if we need to append filename to TargetPath
            // see https://docs.nuget.org/create/nuspec-reference#specifying-files-to-include-in-the-package
            // SourcePath specifies file and target specifies file - do nothing
            // SourcePath specifies file and Target specifies directory - copy filename
            // SourcePath specifies wildcard files - copy wildcard
            // SourcePath specifies recursive wildcard - do not allow, recursive directory may impact asset selection
            //   we don't want to attempt to expand the wildcard since the build may not yet be complete.

            if (SourcePath.Contains("**"))
            {
                throw new ArgumentException($"Recursive wildcards \"**\" are not permitted in source paths for packages: {SourcePath}.  Recursive directory may impact asset selection and we don't want to attempt to expand the wildcard since the build may not yet be complete.");
            }

            string sourceFile = Path.GetFileName(SourcePath);
            if (!Path.GetExtension(TargetPath).Equals(Path.GetExtension(sourceFile), StringComparison.OrdinalIgnoreCase) ||
                sourceFile.Contains("*"))
            {
                TargetPath = Path.Combine(TargetPath, sourceFile);
            }

            // standardize to /
            TargetPath = TargetPath.Replace('\\', '/');

            int dirLength = TargetPath.LastIndexOf('/');
            TargetDirectory = (dirLength > 0) ? TargetPath.Substring(0, dirLength) : String.Empty;
        }
开发者ID:roncain,项目名称:buildtools,代码行数:46,代码来源:PackageItem.cs

示例15: UpdateProperties

        public void UpdateProperties(string propertyOverrides, ITaskItem project, TaskLoggingHelper log)
        {
            log.LogMessage(MessageImportance.Normal, "Updating properties in file {0}", resourceFile.FullName);

            if (string.IsNullOrWhiteSpace(propertyOverrides)) return;

            var properties = propertyOverrides.ToDictionary(';', '=');

            // Scan meta data for project-specific overrides
            var metaDataNames = project.MetadataNames;
            foreach (string metaDataName in metaDataNames)
            {
                properties[metaDataName] = project.GetMetadata(metaDataName);
            }

            var lines = File.ReadLines(resourceFile.FullName).ToList();
            var results = new List<string>(lines.Count);

            // Now process each line in the file)
            foreach (var line in lines)
            {
                var key = GetKey(line);

                if (key == null)
                {
                    results.Add(line);
                }
                else
                {
                    var isValueKey = false;

                    if (key.Equals("VALUE", StringComparison.OrdinalIgnoreCase))
                    {
                        key = GetValueKey(line);
                        if (string.IsNullOrEmpty(key))
                        {
                            results.Add(line);
                            continue;
                        }

                        isValueKey = true;
                    }

                    if (properties.ContainsKey(key))
                    {
                        log.LogMessage(MessageImportance.Low, "Setting \"{0}\" to \"{1}\"", key, properties[key]);
                        results.Add(string.Format(isValueKey ? "VALUE \"{0}\", \"{1}\\0\"" : "{0} {1}", key, properties[key]));
                    }
                    else
                    {
                        results.Add(line);
                    }
                }
            }

            File.WriteAllLines(resourceFile.FullName, results);
        }
开发者ID:DavidMoore,项目名称:Foundation,代码行数:57,代码来源:VisualCResourceFile.cs


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