本文整理汇总了C#中PackageReferenceFile.Select方法的典型用法代码示例。如果您正苦于以下问题:C# PackageReferenceFile.Select方法的具体用法?C# PackageReferenceFile.Select怎么用?C# PackageReferenceFile.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageReferenceFile
的用法示例。
在下文中一共展示了PackageReferenceFile.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFiles
private void AddFiles(PackageBuilder builder, string itemType, string targetFolder)
{
// Skip files that are added by dependency packages
string packagesConfig = GetPackagesConfig();
IPackageRepository repository = GetPackagesRepository();
var contentFilesInDependencies = new List<IPackageFile>();
if (packagesConfig != null && repository != null)
{
var references = new PackageReferenceFile(packagesConfig).GetPackageReferences();
contentFilesInDependencies = references.Select(reference => repository.FindPackage(reference.Id, reference.Version))
.Where(a => a != null)
.SelectMany(a => a.GetContentFiles())
.ToList();
}
// Get the content files from the project
foreach (var item in _project.GetItems(itemType))
{
string fullPath = item.GetMetadataValue("FullPath");
if (_excludeFiles.Contains(Path.GetFileName(fullPath)))
{
continue;
}
string targetFilePath = GetTargetPath(item);
if (!File.Exists(fullPath))
{
Logger.Log(MessageLevel.Warning, NuGetResources.Warning_FileDoesNotExist, targetFilePath);
continue;
}
// Check that file is added by dependency
string targetPath = Path.Combine(targetFolder, targetFilePath);
IPackageFile targetFile = contentFilesInDependencies.Find(a => a.Path.Equals(targetPath, StringComparison.OrdinalIgnoreCase));
if (targetFile != null)
{
// Compare contents as well
var isEqual = ContentEquals(targetFile, fullPath);
if (isEqual)
{
Logger.Log(MessageLevel.Info, NuGetResources.PackageCommandFileFromDependencyIsNotChanged, targetFilePath);
continue;
}
Logger.Log(MessageLevel.Info, NuGetResources.PackageCommandFileFromDependencyIsChanged, targetFilePath);
}
builder.Files.Add(new PhysicalPackageFile
{
SourcePath = fullPath,
TargetPath = targetPath
});
}
}