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


C# PackageReferenceFile.Select方法代码示例

本文整理汇总了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
                });
            }
        }
开发者ID:atheken,项目名称:nuget,代码行数:56,代码来源:ProjectFactory.cs


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