• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PackageIdentity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PackageIdentity的典型用法代码示例。如果您正苦于以下问题:C# PackageIdentity类的具体用法?C# PackageIdentity怎么用?C# PackageIdentity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PackageIdentity类属于命名空间,在下文中一共展示了PackageIdentity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Parse

        public static ServerPackageMetadata Parse(IPackage package)
        {
            var Version = NuGetVersion.Parse(package.Version.ToString());
            var Published = package.Published;
            var title = String.IsNullOrEmpty(package.Title) ? package.Id : package.Title;
            var summary = package.Summary;
            var desc = package.Description;
            //*TODOs: Check if " " is the separator in the case of V3 jobjects ...
            var authors = package.Authors;
            var owners = package.Owners;
            var iconUrl = package.IconUrl;
            var licenseUrl = package.LicenseUrl;
            var projectUrl = package.ProjectUrl;
            IEnumerable<string> tags = package.Tags == null ? new string[0] : package.Tags.Split(' ');
            var dependencySets = package.DependencySets.Select(p => GetVisualStudioUIPackageDependencySet(p));
            var requiresLiceneseAcceptance = package.RequireLicenseAcceptance;

            var identity = new PackageIdentity(package.Id, Version);

            NuGetVersion minClientVersion = null;

            if (package.MinClientVersion != null)
            {
                NuGetVersion.TryParse(package.MinClientVersion.ToString(), out minClientVersion);
            }

            var downloadCount = package.DownloadCount;

            // This concept is not in v2 yet
            IEnumerable<string> types = new string[] { "Package" };

            return new ServerPackageMetadata(
                identity, title, summary, desc, authors, iconUrl, licenseUrl,
                projectUrl, tags, Published, dependencySets, requiresLiceneseAcceptance, minClientVersion, downloadCount, -1, owners, types);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:35,代码来源:ParsePackageMetadataV2.cs


示例2: Extract

		public static async Task Extract (
			Solution solution,
			PackageIdentity packageIdentity,
			DownloadResourceResult downloadResult,
			CancellationToken token)
		{
			string globalPackagesFolder = await GetPackagesDirectory (solution);

			var defaultPackagePathResolver = new VersionFolderPathResolver (globalPackagesFolder);

			string hashPath = defaultPackagePathResolver.GetHashPath (packageIdentity.Id, packageIdentity.Version);

			if (File.Exists (hashPath))
				return;

			var versionFolderPathContext = new VersionFolderPathContext (
				packageIdentity,
				globalPackagesFolder,
				NullLogger.Instance,
				PackageSaveMode.Defaultv3,
				PackageExtractionBehavior.XmlDocFileSaveMode);

			downloadResult.PackageStream.Position = 0;
			await PackageExtractor.InstallFromSourceAsync (
				stream => downloadResult.PackageStream.CopyToAsync (stream, BufferSize, token),
				versionFolderPathContext,
				token);
		}
开发者ID:PlayScriptRedux,项目名称:monodevelop,代码行数:28,代码来源:GlobalPackagesExtractor.cs


示例3: GetPackageStream

        /// <summary>
        /// Sets <param name="targetPackageStream"></param> for a given <param name="packageIdentity"></param> 
        /// from the given <param name="sourceRepository"></param>. If successfully set, returns true. Otherwise, false
        /// </summary>
        public static async Task<bool> GetPackageStream(SourceRepository sourceRepository, PackageIdentity packageIdentity, Stream targetPackageStream, CancellationToken token)
        {
            // TODO: Tie up machine cache with CacheClient?!

            try
            {
                token.ThrowIfCancellationRequested();
                // Step-1 : Get the download stream for packageIdentity
                Stream downloadStream = await GetDownloadStream(sourceRepository, packageIdentity, token);

                if(downloadStream == null)
                {
                    return false;
                }

                token.ThrowIfCancellationRequested();
                // Step-2: Copy download stream to targetPackageStream if it is not null
                await downloadStream.CopyToAsync(targetPackageStream);
                return true;
            }
            catch (Exception)
            {
                return false;
            } 
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:29,代码来源:PackageDownloader.cs


示例4: TestFolderNuGetProjectInstall

        public async Task TestFolderNuGetProjectInstall()
        {
            // Arrange
            var packageIdentity = new PackageIdentity("packageA", new NuGetVersion("1.0.0"));
            var randomTestSourcePath = TestFilesystemUtility.CreateRandomTestFolder();
            var packageFileInfo = TestPackages.GetLegacyTestPackage(randomTestSourcePath, packageIdentity.Id, packageIdentity.Version.ToNormalizedString());
            var randomTestDestinationPath = TestFilesystemUtility.CreateRandomTestFolder();
            var folderNuGetProject = new FolderNuGetProject(randomTestDestinationPath);
            var packagePathResolver = new PackagePathResolver(randomTestDestinationPath);
            var packageInstallPath = packagePathResolver.GetInstallPath(packageIdentity);
            var nupkgFilePath = Path.Combine(packageInstallPath, packagePathResolver.GetPackageFileName(packageIdentity));
            var testNuGetProjectContext = new TestNuGetProjectContext();
            var token = CancellationToken.None;
            using(var packageStream = packageFileInfo.OpenRead())
            {
                // Act
                await folderNuGetProject.InstallPackageAsync(packageIdentity, packageStream, testNuGetProjectContext, token);
            }

            // Assert
            Assert.True(File.Exists(nupkgFilePath));
            Assert.True(File.Exists(Path.Combine(packageInstallPath, "lib/test.dll")));
            using(var packageStream = File.OpenRead(nupkgFilePath))
            {
                var zipArchive = new ZipArchive(packageStream);
                Assert.Equal(5, zipArchive.Entries.Count);
            }

            // Clean-up
            TestFilesystemUtility.DeleteRandomTestFolders(randomTestSourcePath, randomTestDestinationPath);
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:31,代码来源:FolderNuGetProjectTests.cs


示例5: ResolvePackage

        /// <summary>
        /// Retrieve dependency info for a single package.
        /// </summary>
        /// <param name="package">package id and version</param>
        /// <param name="projectFramework">project target framework. This is used for finding the dependency group</param>
        /// <param name="token">cancellation token</param>
        /// <returns>
        /// Returns dependency info for the given package if it exists. If the package is not found null is
        /// returned.
        /// </returns>
        public override async Task<SourcePackageDependencyInfo> ResolvePackage(PackageIdentity package, NuGetFramework projectFramework, CancellationToken token)
        {
            try
            {
                SourcePackageDependencyInfo result = null;

                // Construct the registration index url
                var uri = _regResource.GetUri(package.Id);

                // Retrieve the registration blob
                var singleVersion = new VersionRange(minVersion: package.Version, includeMinVersion: true, maxVersion: package.Version, includeMaxVersion: true);
                var regInfo = await ResolverMetadataClient.GetRegistrationInfo(_client, uri, singleVersion, projectFramework, token);

                // regInfo is null if the server returns a 404 for the package to indicate that it does not exist
                if (regInfo != null)
                {
                    // Parse package and dependeny info from the blob
                    result = GetPackagesFromRegistration(regInfo, token).FirstOrDefault();
                }

                return result;
            }
            catch (Exception ex)
            {
                // Wrap exceptions coming from the server with a user friendly message
                var error = String.Format(CultureInfo.CurrentUICulture, Strings.Protocol_PackageMetadataError, package, _source);

                throw new NuGetProtocolException(error, ex);
            }
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:40,代码来源:DependencyInfoResourceV3.cs


示例6: CheckIfPackageCanBeUninstalled

        private static void CheckIfPackageCanBeUninstalled(PackageIdentity packageIdentity,
            IDictionary<PackageIdentity, HashSet<PackageIdentity>> dependenciesDict,
            IDictionary<PackageIdentity, HashSet<PackageIdentity>> dependentsDict,
            UninstallationContext uninstallationContext,
            HashSet<PackageIdentity> packagesMarkedForUninstall)
        {
            HashSet<PackageIdentity> dependents;
            if (dependentsDict.TryGetValue(packageIdentity, out dependents) && dependents != null)
            {
                if (!uninstallationContext.ForceRemove)
                {
                    var unMarkedDependents = dependents.Where(d => !packagesMarkedForUninstall.Contains(d)).ToList();
                    if (unMarkedDependents.Count > 0)
                    {
                        throw CreatePackageHasDependentsException(packageIdentity, unMarkedDependents);
                    }
                }
            }

            HashSet<PackageIdentity> dependencies;
            if (uninstallationContext.RemoveDependencies && dependenciesDict.TryGetValue(packageIdentity, out dependencies) && dependencies != null)
            {
                foreach(var dependency in dependencies)
                {
                    CheckIfPackageCanBeUninstalled(dependency,
                        dependenciesDict,
                        dependentsDict,
                        uninstallationContext,
                        packagesMarkedForUninstall);
                }
            }
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:32,代码来源:UninstallResolver.cs


示例7: Search

        public override async Task<IEnumerable<ServerPackageMetadata>> Search(string searchTerm, SearchFilter filters, int skip, int take, CancellationToken cancellationToken)
        {
            List<ServerPackageMetadata> results = new List<ServerPackageMetadata>();

            var searchResultJsonObjects = await _searchResource.Search(searchTerm, filters, skip, take, cancellationToken);

            foreach (JObject package in searchResultJsonObjects)
            {
                // TODO: verify this parsing is needed
                string id = package.Value<string>(Properties.PackageId);
                NuGetVersion version = NuGetVersion.Parse(package.Value<string>(Properties.Version));
                PackageIdentity topPackage = new PackageIdentity(id, version);
                Uri iconUrl = GetUri(package, Properties.IconUrl);
                string summary = package.Value<string>(Properties.Summary);

                if (string.IsNullOrWhiteSpace(summary))
                {
                    // summary is empty. Use its description instead.
                    summary = package.Value<string>(Properties.Description);
                }

                // retrieve metadata for the top package
                results.Add(PackageMetadataParser.ParseMetadata(package));
            }

            return results;
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:27,代码来源:SearchLatestResourceV3.cs


示例8: RemoveAllVersionsForIdExcept

        /// <summary>
        /// Remove all versions of a package id from the list, except for the target version
        /// </summary>
        public static IEnumerable<SourceDependencyInfo> RemoveAllVersionsForIdExcept(IEnumerable<SourceDependencyInfo> packages, PackageIdentity target)
        {
            var comparer = VersionComparer.VersionRelease;

            return packages.Where(p => !StringComparer.OrdinalIgnoreCase.Equals(target.Id, p.Id) ||
                (StringComparer.OrdinalIgnoreCase.Equals(target.Id, p.Id) && comparer.Equals(p.Version, target.Version)));
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:10,代码来源:PrunePackageTree.cs


示例9: GetStream

        public override async Task<Stream> GetStream(PackageIdentity identity, CancellationToken token)
        {
            Stream result = null;
            IPackage package = null;

            SemanticVersion version = SemanticVersion.Parse(identity.Version.ToString());

            // attempt a normal lookup first
            if (!V2Client.TryFindPackage(identity.Id, version, out package))
            {
                // skip further look ups for online repos
                DataServicePackageRepository v2Online = V2Client as DataServicePackageRepository;

                if (v2Online == null)
                {
                    IVersionComparer versionComparer = VersionComparer.VersionRelease;

                    // otherwise search further to find the package - this is needed for v2 non-normalized versions
                    V2Client.FindPackagesById(identity.Id).Any(p => versionComparer.Equals(identity.Version, NuGetVersion.Parse(p.ToString())));
                }
            }

            if (package != null)
            {
                result = package.GetStream();
            }

            return result;
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:29,代码来源:DownloadResourceV2.cs


示例10: GetPackageDependents

        public static IDictionary<PackageIdentity, HashSet<PackageIdentity>> GetPackageDependents(IEnumerable<PackageDependencyInfo> dependencyInfoEnumerable,
            IEnumerable<PackageIdentity> installedPackages, out IDictionary<PackageIdentity, HashSet<PackageIdentity>> dependenciesDict)
        {
            Dictionary<PackageIdentity, HashSet<PackageIdentity>> dependentsDict = new Dictionary<PackageIdentity, HashSet<PackageIdentity>>(PackageIdentity.Comparer);
            dependenciesDict = new Dictionary<PackageIdentity, HashSet<PackageIdentity>>(PackageIdentity.Comparer);
            foreach (var dependencyInfo in dependencyInfoEnumerable)
            {
                var packageIdentity = new PackageIdentity(dependencyInfo.Id, dependencyInfo.Version);
                foreach(var dependency in dependencyInfo.Dependencies)
                {
                    var dependencyPackageIdentity = installedPackages.Where(i => dependency.Id.Equals(i.Id, StringComparison.OrdinalIgnoreCase)
                        && dependency.VersionRange.Satisfies(i.Version)).FirstOrDefault();
                    if(dependencyPackageIdentity != null)
                    {
                        // Update the package dependents dictionary
                        HashSet<PackageIdentity> dependents;
                        if(!dependentsDict.TryGetValue(dependencyPackageIdentity, out dependents))
                        {
                            dependentsDict[dependencyPackageIdentity] = dependents = new HashSet<PackageIdentity>(PackageIdentity.Comparer);
                        }
                        dependents.Add(packageIdentity);

                        // Update the package dependencies dictionary
                        HashSet<PackageIdentity> dependencies;
                        if(!dependenciesDict.TryGetValue(packageIdentity, out dependencies))
                        {
                            dependenciesDict[packageIdentity] = dependencies = new HashSet<PackageIdentity>(PackageIdentity.Comparer);
                        }
                        dependencies.Add(dependencyPackageIdentity);
                    }
                }
            }

            return dependentsDict;
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:35,代码来源:UninstallResolver.cs


示例11: RemoveAllVersionsLessThan

        /// <summary>
        /// Clear out all versions less than the minimuim. This can be used to prevent downgrading
        /// </summary>
        public static IEnumerable<SourceDependencyInfo> RemoveAllVersionsLessThan(IEnumerable<SourceDependencyInfo> packages, PackageIdentity minimum)
        {
            var comparer = VersionComparer.VersionRelease;

            return packages.Where(p => !StringComparer.OrdinalIgnoreCase.Equals(minimum.Id, p.Id) ||
                (StringComparer.OrdinalIgnoreCase.Equals(minimum.Id, p.Id) && comparer.Compare(p.Version, minimum.Version) >= 0));
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:10,代码来源:PrunePackageTree.cs


示例12: Search

        /// <summary>
        /// Basic search
        /// </summary>
        public override async Task<IEnumerable<SimpleSearchMetadata>> Search(string searchTerm, SearchFilter filters, int skip, int take, CancellationToken cancellationToken)
        {
            var results = new List<SimpleSearchMetadata>();

            foreach (var result in await _rawSearch.Search(searchTerm, filters, skip, take, cancellationToken))
            {
                var version = NuGetVersion.Parse(result["version"].ToString());
                var identity = new PackageIdentity(result["id"].ToString(), version);

                var description = result["description"].ToString();

                var allVersions = new List<NuGetVersion>();

                foreach (var versionObj in ((JArray)result["versions"]))
                {
                    allVersions.Add(NuGetVersion.Parse(versionObj["version"].ToString()));
                }

                var data = new SimpleSearchMetadata(identity, description, allVersions);

                results.Add(data);
            }

            return results;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:28,代码来源:SimpleSearchResourceV3.cs


示例13: GetNupkgUrlForDownload

 public Task<PackageDownloadMetadata> GetNupkgUrlForDownload(PackageIdentity identity)
 {
   //*TODOs: Temp implementation. Need to do erorr handling and stuff.
   return Task.Factory.StartNew(() =>
  {
      if(V2Client is DataServicePackageRepository)            
      {
          //TODOs:Not sure if there is some other standard way to get the Url from a dataservice repo. DataServicePackage has downloadurl property but not sure how to get it.
          return new PackageDownloadMetadata(new Uri(Path.Combine(V2Client.Source, "api/v2/" + identity.Id + "." + identity.Version + ".nupkg")));      
      }
      else if(V2Client is LocalPackageRepository)
      {
          LocalPackageRepository lrepo = V2Client as LocalPackageRepository;
          SemanticVersion semVer = new SemanticVersion(identity.Version.Version);
          return new PackageDownloadMetadata(new Uri(Path.Combine(V2Client.Source,  lrepo.PathResolver.GetPackageFileName(identity.Id, semVer))));
      }
      else
      {
          // TODO: move the string into a resoure file
          throw new InvalidOperationException(string.Format(
              CultureInfo.CurrentCulture,
              "Unable to get download metadata for package {0}",identity.Id));
      }
  });
 }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:25,代码来源:V2DownloadResource.cs


示例14: InstallFromStream

        private async ThreadingTask InstallFromStream(Task<Stream> getStream, PackageIdentity package,
            string packagesFolder, CancellationToken token)
        {
            bool isValid = true;
            if (OfflineFeedUtility.PackageExists(package, packagesFolder, out isValid))
            {
                return;
            }

            var logger = new NugetMsBuildLogger(new TaskLoggingHelper(this));

            var versionFolderPathContext = new VersionFolderPathContext(
                package,
                packagesFolder,
                isLowercasePackagesDirectory: false,
                logger: logger,
                packageSaveMode: PackageSaveMode.Defaultv3,
                xmlDocFileSaveMode: XmlDocFileSaveMode.None);

            await PackageExtractor.InstallFromSourceAsync(
                async dest =>
                {
                    var source = await getStream;
                    await source.CopyToAsync(dest, bufferSize: DefaultBufferSize, cancellationToken: token);
                },
                versionFolderPathContext,
                token);
        }
开发者ID:roncain,项目名称:buildtools,代码行数:28,代码来源:InstallPackageFromFile.cs


示例15: InstallPackage

 public override Task InstallPackage(
     PackageIdentity id, 
     IEnumerable<FrameworkName> packageSupportedFrameworks,
     IExecutionLogger logger, 
     CancellationToken cancelToken)
 {
     var args = new Dictionary<string, object>();
     var projectFrameworks = _nugetAwareProject.GetSupportedFrameworksAsync(cancelToken).Result;
     args["Frameworks"] = projectFrameworks.Where(
         projectFramework =>
             NuGet.VersionUtility.IsCompatible(
                 projectFramework,
                 packageSupportedFrameworks)).ToArray();
     var task = _nugetAwareProject.InstallPackageAsync(
         new NuGetPackageMoniker
         {
             Id = id.Id,
             Version = id.Version.ToString()
         },
         args,
         logger: null,
         progress: null,
         cancellationToken: cancelToken);
     return task;
 }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:25,代码来源:VsNuGetAwareProject.cs


示例16: GetCachedPackageInfo

        public async Task GetCachedPackageInfo(string PackageID)
        {
            NuGetFactory factory = new NuGetFactory("NuGet", "https://api.nuget.org/v3/index.json");
            var metaResource = await factory.GetUIMetadata();
            var searchResource = await factory.GetSearch();

            var packageMeta = await searchResource.Search(PackageID, new SearchFilter { IncludePrerelease = true }, 0, 100, CancellationToken.None);
            var packagesFound = packageMeta.Where(x => x.Identity.Id.Equals(PackageID, StringComparison.InvariantCultureIgnoreCase)).ToList();

            Assert.False(packagesFound.Count == 0);
            Assert.True(packagesFound.Count > 0);

            var nugetPackage = packagesFound.First();
            var versions = await (await factory.GetMetadata()).GetVersions(PackageID, CancellationToken.None);

            foreach (var version in versions)
            {
                var versionIdentity = new PackageIdentity(nugetPackage.Identity.Id, version);
                var meta = await metaResource.GetMetadata(versionIdentity, CancellationToken.None);
                foreach (var item in meta.DependencySets)
                {
                    Assert.NotNull(item.TargetFramework.Framework);
                }
            }
        }
开发者ID:punitganshani,项目名称:NuGetViz,代码行数:25,代码来源:NuGetTests.cs


示例17: InstallPackageByIdentityAsync

        /// <summary>
        /// Install package by Identity
        /// </summary>
        /// <param name="project"></param>
        /// <param name="identity"></param>
        /// <param name="resolutionContext"></param>
        /// <param name="projectContext"></param>
        /// <param name="isPreview"></param>
        /// <param name="isForce"></param>
        /// <param name="uninstallContext"></param>
        /// <returns></returns>
        protected async Task InstallPackageByIdentityAsync(NuGetProject project, PackageIdentity identity, ResolutionContext resolutionContext, INuGetProjectContext projectContext, bool isPreview, bool isForce = false, UninstallationContext uninstallContext = null)
        {
            List<NuGetProjectAction> actions = new List<NuGetProjectAction>();
            // For Install-Package -Force
            if (isForce)
            {
                PackageReference installedReference = project.GetInstalledPackagesAsync(CancellationToken.None).Result.Where(p =>
                    StringComparer.OrdinalIgnoreCase.Equals(identity.Id, p.PackageIdentity.Id)).FirstOrDefault();
                if (installedReference != null)
                {
                    actions.AddRange(await PackageManager.PreviewUninstallPackageAsync(project, installedReference.PackageIdentity, uninstallContext, projectContext, CancellationToken.None));
                }
                NuGetProjectAction installAction = NuGetProjectAction.CreateInstallProjectAction(identity, ActiveSourceRepository);
                actions.Add(installAction);
            }
            else
            {
                actions.AddRange(await PackageManager.PreviewInstallPackageAsync(project, identity, resolutionContext, projectContext, ActiveSourceRepository, null, CancellationToken.None));
            }

            if (isPreview)
            {
                PreviewNuGetPackageActions(actions);
            }
            else
            {
                await PackageManager.ExecuteNuGetProjectActionsAsync(project, actions, this, CancellationToken.None);
            }
        }
开发者ID:mauroa,项目名称:NuGet.VisualStudioExtension,代码行数:40,代码来源:PackageActionBaseCommand.cs


示例18: Index

        public async Task<ActionResult> Index()
        {
            TestModel model = new TestModel();
            model.Result = new List<string>();

            var provider = RepositoryFactory.CreateProvider(new string[] { "https://api.nuget.org/v3/index.json", "https://nuget.org/api/v2" });

            var id = new PackageIdentity("newtonsoft.json", NuGetVersion.Parse("6.0.4"));

            foreach (var source in provider.GetRepositories())
            {
                var resource = await source.GetResourceAsync<DownloadResource>();
                var uri = await resource.GetDownloadUrl(id);
                var stream = await resource.GetStream(id, CancellationToken.None);
            }

            model.Result.Add("DownloadResource");

            foreach (var source in provider.GetRepositories())
            {
                var resource = await source.GetResourceAsync<UISearchResource>();
                var results = await resource.Search("elmah", new SearchFilter(), 0, 10, CancellationToken.None);
            }

            model.Result.Add("UISearchResource");

            return View(model);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:28,代码来源:HomeController.cs


示例19: TestUninstallLastPackage

        public async Task TestUninstallLastPackage()
        {
            // Arrange
            var randomTestFolder = TestFilesystemUtility.CreateRandomTestFolder();
            var packagesConfigFileName = "packages.config";
            var targetFramework = NuGetFramework.Parse("net45");
            var metadata = new Dictionary<string, object>()
            {
                { NuGetProjectMetadataKeys.TargetFramework, targetFramework},
            };
            var packagesConfigFullPath = Path.Combine(randomTestFolder, packagesConfigFileName);
            var packagesConfigNuGetProject = new PackagesConfigNuGetProject(packagesConfigFullPath, metadata);
            var packageIdentity = new PackageIdentity("A", new NuGetVersion("1.0.0"));
            var testNuGetProjectContext = new TestNuGetProjectContext();
            var token = CancellationToken.None;
            MakeFileReadOnly(packagesConfigFullPath);

            // Act
            await packagesConfigNuGetProject.InstallPackageAsync(packageIdentity, Stream.Null, testNuGetProjectContext, token);
            MakeFileReadOnly(packagesConfigFullPath);

            // Assert
            var installedPackagesList = (await packagesConfigNuGetProject.GetInstalledPackagesAsync(token)).ToList();
            Assert.Equal(1, installedPackagesList.Count);
            Assert.Equal(packageIdentity, installedPackagesList[0].PackageIdentity);
            Assert.Equal(targetFramework, installedPackagesList[0].TargetFramework);

            // Main Act
            await packagesConfigNuGetProject.UninstallPackageAsync(packageIdentity, testNuGetProjectContext, token);

            // Main Assert
            installedPackagesList = (await packagesConfigNuGetProject.GetInstalledPackagesAsync(token)).ToList();
            Assert.Equal(0, installedPackagesList.Count);
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:34,代码来源:PackagesConfigNuGetProjectTests.cs


示例20: PackageOperationEventArgs

 public PackageOperationEventArgs(string installPath, PackageIdentity package, string fileSystemRoot)
 {
     Package = package;
     InstallPath = installPath;
     //FileSystem = fileSystem;
     FileSystemRoot = fileSystemRoot;
 }
开发者ID:mauroa,项目名称:NuGet.VisualStudioExtension,代码行数:7,代码来源:PackageOperationEventArgs.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PackageInfo类代码示例发布时间:2022-05-24
下一篇:
C# PackageDescriptor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap