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


C# ITaskItem.GetTargetFrameworkMoniker方法代码示例

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


在下文中一共展示了ITaskItem.GetTargetFrameworkMoniker方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertToPackageFile

 private static ITaskItem ConvertToPackageFile(ITaskItem output)
 {
     var fileName = output.ItemSpec;
     var frameworkNameMoniker = output.GetTargetFrameworkMoniker();
     var packageDirectory = output.GetPackageDirectory();
     var targetFramework = frameworkNameMoniker.GetShortFrameworkName();
     var metadata = output.CloneCustomMetadata();
     metadata[Metadata.TargetFramework] = targetFramework;
     metadata[Metadata.PackageDirectory] = packageDirectory.ToString();
     metadata[Metadata.FileTarget] = packageDirectory.Combine(targetFramework, Path.GetFileName(fileName));
     return new TaskItem(fileName, metadata);
 }
开发者ID:stffabi,项目名称:nuproj,代码行数:12,代码来源:AssignTargetFramework.cs

示例2: ConvertToPackageFile

 private static ITaskItem ConvertToPackageFile(ITaskItem output)
 {
     var fileName = output.ItemSpec;
     var targetPath = output.GetMetadata("TargetPath");
     targetPath = string.IsNullOrEmpty(targetPath) ? Path.GetFileName(fileName) : targetPath;
     var frameworkNameMoniker = output.GetTargetFrameworkMoniker();
     var packageDirectory = output.GetPackageDirectory();
     var targetSubdirectory = output.GetTargetSubdirectory();
     var targetFramework = packageDirectory == PackageDirectory.Analyzers
         ? frameworkNameMoniker.GetAnalyzersFrameworkName()
         : frameworkNameMoniker.GetShortFrameworkName();
     var metadata = output.CloneCustomMetadata();
     metadata[Metadata.TargetFramework] = targetFramework;
     metadata[Metadata.PackageDirectory] = packageDirectory.ToString();
     metadata[Metadata.TargetSubdirectory] = targetSubdirectory;
     metadata[Metadata.FileTarget] = packageDirectory.Combine(targetFramework, targetSubdirectory, targetPath);
     return new TaskItem(fileName, metadata);
 }
开发者ID:kovalikp,项目名称:nuproj,代码行数:18,代码来源:AssignTargetFramework.cs

示例3: EnsurePackagePath

		ITaskItem EnsurePackagePath(ITaskItem file, IDictionary<string, string> kindMap)
		{
			if (!string.IsNullOrEmpty(file.GetMetadata("PackagePath")))
				return new TaskItem(file);

			var kind = file.GetMetadata("Kind");
			if (string.IsNullOrEmpty(kind))
			{
				Log.LogErrorCode(nameof(ErrorCode.NP0010), ErrorCode.NP0010(file.ItemSpec));
				// We return the file anyway, since the task result will still be false.
				return file;
			}

			// Map the Kind to a target top-level directory.
			string packageFolder;
			if (!kindMap.TryGetValue(kind, out packageFolder))
			{
				// By convention, we just turn the first letter of Kind to lowercase and assume that 
				// to be a valid folder kind.
				packageFolder = char.IsLower(kind[0]) ? kind :
					char.ToLower(kind[0]).ToString() + kind.Substring(1);
			}

			var output = new TaskItem(file);
			output.SetMetadata(MetadataName.PackageFolder, packageFolder);

			var frameworkMoniker = file.GetTargetFrameworkMoniker();
			var targetFramework = frameworkMoniker.GetShortFrameworkName() ?? "";

			// Special case for contentFiles, since they can also provide a codeLanguage metadata
			if (packageFolder == PackagingConstants.Folders.ContentFiles)
			{
				/// See https://docs.nuget.org/create/nuspec-reference#contentfiles-with-visual-studio-2015-update-1-and-later
				var codeLanguage = file.GetMetadata(nameof(PropertyNames.CodeLanguage));
				if (string.IsNullOrEmpty(codeLanguage))
					codeLanguage = PackagingConstants.AnyFramework;

				packageFolder = Path.Combine(packageFolder, codeLanguage);

				// And they also cannot have an empty framework, at most, it will be "any"
				if (string.IsNullOrEmpty(targetFramework))
					targetFramework = PackagingConstants.AnyFramework;
			}

			var targetPath = file.GetMetadata("TargetPath");
			if (string.IsNullOrEmpty(targetPath))
				targetPath = file.GetMetadata("FileName") + file.GetMetadata("Extension");

			// None files or those for which we know no mapping, go straight to the root folder of the package.
			// This allows custom packaging paths such as "workbooks", "docs" or whatever, which aren't prohibited by 
			// the format.
			var packagePath = string.IsNullOrEmpty(packageFolder) ?
				// File goes to the determined target path (or the root of the package), such as a readme.txt
				targetPath :
				// Otherwise, it goes to a framework-specific folder.
				Path.Combine(new[] { packageFolder, targetFramework }.Concat(targetPath.Split(Path.DirectorySeparatorChar)).ToArray());

			output.SetMetadata(MetadataName.TargetFramework, targetFramework);
			output.SetMetadata(MetadataName.PackagePath, packagePath);

			return output;
		}
开发者ID:xamarin,项目名称:NuGetizer3000,代码行数:62,代码来源:AssignPackagePath.cs


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