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


C# PackageReferenceFile.EntryExists方法代码示例

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


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

示例1: CreatePackagesConfig

 private void CreatePackagesConfig(ICollection<IPackage> packagesToAdd, FrameworkName targetFramework = null)
 {
     _console.WriteLine("Creating {0}", PackageReferenceFilename);
     var packagesConfig = new PackageReferenceFile(_projectFileSystem, PackageReferenceFilename);
     foreach (var package in packagesToAdd)
     {
         if (!packagesConfig.EntryExists(package.Id, package.Version)) //Note we don't re-add entries that have the wrong targetFramework set
         {
             packagesConfig.AddEntry(package.Id, package.Version, false, targetFramework);
         }
     }
 }
开发者ID:GrahamTheCoder,项目名称:NuGet.Extensions,代码行数:12,代码来源:ProjectNugetifier.cs

示例2: WillChoosePackageWithSmallestNumberOfAssembliesFromMultipleMatches

        public void WillChoosePackageWithSmallestNumberOfAssembliesFromMultipleMatches()
        {
            var packages = new List<IPackage> 
            {
                PackageUtility.CreatePackage(AssemblyCommon, "1.0", assemblyReferences: new List<string>() { AssemblyCommonDll }),
                PackageUtility.CreatePackage("Assembly.Other", "1.0", assemblyReferences: new List<string>() { AssemblyCommonDll, "Assembly.Other.dll" }) 
            };

            var assemblies = new List<string>() { AssemblyCommonDll };
            var filesystem = new MockFileSystem();

            var assemblyResolver = new RepositoryAssemblyResolver(assemblies, packages.AsQueryable(), filesystem, new Mock<IConsole>().Object);
            var resolved = assemblyResolver.GetAssemblyToPackageMapping(false);
            resolved.OutputPackageConfigFile();
            Assert.AreEqual(1, filesystem.Paths.Count);
            var file = new PackageReferenceFile(filesystem, string.Concat(filesystem.Root, ".\\packages.config"));
            Assert.AreEqual(1, file.GetPackageReferences().Count());
            Assert.AreEqual(true, file.EntryExists(AssemblyCommon,SemanticVersion.Parse("1.0")));
        }
开发者ID:GrahamTheCoder,项目名称:NuGet.Extensions,代码行数:19,代码来源:RepositoryAssemblyResolverTests.cs

示例3: CreateNuGetScaffolding

        private void CreateNuGetScaffolding(SharedPackageRepository sharedPackagesRepository, List<ManifestDependency> manifestDependencies, IEnumerable<KeyValuePair<string, List<IPackage>>> resolvedMappings, FileInfo projectFileInfo, Project project, List<string> projectDependencies)
        {
            //Now, create the packages.config for the resolved packages, and update the repositories.config
            Console.WriteLine("Creating packages.config");
            var packagesConfigFilePath = Path.Combine(projectFileInfo.Directory.FullName + "\\", "packages.config");
            var packagesConfig = new PackageReferenceFile(packagesConfigFilePath);
            foreach (var referenceMapping in resolvedMappings)
            {
                //TODO We shouldnt need to resolve this twice....
                var package = referenceMapping.Value.OrderBy(p => p.GetFiles().Count()).First();
                if (!packagesConfig.EntryExists(package.Id, package.Version))
                    packagesConfig.AddEntry(package.Id, package.Version);
                if (NuSpec && manifestDependencies.All(m => m.Id != package.Id))
                {
                    manifestDependencies.Add(new ManifestDependency {Id = package.Id});
                }
            }

            //This is messy...refactor
            //For any resolved project dependencies, add a manifest dependency if we are doing nuspecs
            if (NuSpec)
            {
                foreach (var projectDependency in projectDependencies)
                {
                    if (manifestDependencies.All(m => m.Id != projectDependency))
                    {
                        manifestDependencies.Add(new ManifestDependency {Id = projectDependency});
                    }
                }
            }
            //Register the packages.config
            sharedPackagesRepository.RegisterRepository(packagesConfigFilePath);

            //Add the packages.config to the project content, otherwise later versions of the VSIX fail...
            if (!project.GetItems("None").Any(i => i.UnevaluatedInclude.Equals("packages.config")))
            {
                project.Xml.AddItemGroup().AddItem("None", "packages.config");
                project.Save();
            }
        }
开发者ID:dipeshc,项目名称:NuGet.Extensions,代码行数:40,代码来源:Nugetify.cs


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