コード例 #1
0
ファイル: ReadPackagesConfig.cs プロジェクト: NN---/nuproj
        protected ITaskItem ConvertPackageElement(ITaskItem project, PackageReference packageReference)
        {
            var id = packageReference.Id;
            var version = packageReference.Version;
            var targetFramework = packageReference.TargetFramework;
            var isDevelopmentDependency = packageReference.IsDevelopmentDependency;
            var requireReinstallation = packageReference.RequireReinstallation;
            var versionConstraint = packageReference.VersionConstraint;

            var item = new TaskItem(id);
            project.CopyMetadataTo(item);

            var packageDirectoryPath = GetPackageDirectoryPath(project.GetMetadata("FullPath"), id, version);
            item.SetMetadata("PackageDirectoryPath", packageDirectoryPath);
            item.SetMetadata("ProjectPath", project.GetMetadata("FullPath"));

            item.SetMetadata("IsDevelopmentDependency", isDevelopmentDependency.ToString());
            item.SetMetadata("RequireReinstallation", requireReinstallation.ToString());

            if (version != null)
                item.SetMetadata(Metadata.Version, version.ToString());

            if (targetFramework != null)
                item.SetMetadata(Metadata.TargetFramework, targetFramework.GetShortFrameworkName());

            if (versionConstraint != null)
                item.SetMetadata("VersionConstraint", versionConstraint.ToString());

            return item;
        }
コード例 #2
0
		void CreateUpdatePackageInAllProjects(string packageId, SemanticVersion version)
		{
			fakeSolution = new FakePackageManagementSolution();
			fakeSourceRepository = new FakePackageRepository();
			var packageReference = new PackageReference(packageId, version, null, null, false, false);
			updatePackageInAllProjects = new UpdatePackageInAllProjects(packageReference, fakeSolution, fakeSourceRepository);
		}
コード例 #3
0
		public bool IsRestored (PackageReference packageReference)
		{
			return FakeSharedRepository.FakePackages.Any (package => {
				return (package.Id == packageReference.Id) &&
					(package.Version == packageReference.Version);
			});
		}
コード例 #4
0
		string ConvertToString(PackageReference packageReference)
		{
			return String.Format(
				"Id: {0}, Version: {1}",
				packageReference.Id,
				packageReference.Version);
		}
コード例 #5
0
        public IUpdatePackageActions CreateUpdatePackageInAllProjects(
			PackageReference packageReference,
			IPackageManagementSolution solution,
			IPackageRepository sourceRepository)
        {
            return new UpdatePackageInAllProjects(packageReference, solution, sourceRepository);
        }
コード例 #6
0
		void CreatePackageReference (
			string packageId = "Id",
			bool requireReinstallation = false)
		{
			var version = new SemanticVersion ("1.2.3");
			packageReference = new PackageReference (packageId, version, null, null, false, requireReinstallation);
		}
		ReinstallPackageAction CreateReinstallPackageAction (IPackageManagementProject project, PackageReference packageReference)
		{
			ReinstallPackageAction action = project.CreateReinstallPackageAction ();
			action.PackageId = packageReference.Id;
			action.PackageVersion = packageReference.Version;

			return action;
		}
		public UpdatePackageInAllProjects (
			PackageReference packageReference,
			IPackageManagementSolution2 solution,
			IPackageRepository sourceRepository)
		{
			this.packageReference = packageReference;
			this.solution = solution;
			this.sourceRepository = sourceRepository;
		}
コード例 #9
0
		PackageReference AddPackageReferenceToProject (
			string packageId = "Id",
			string version = "1.2.3")
		{
			var semanticVersion = new SemanticVersion (version);
			var packageReference = new PackageReference (packageId, semanticVersion, null, null, false, false);
			packagesFolderNode.PackageReferences.Add (packageReference);
			return packageReference;
		}
コード例 #10
0
		 public IUpdatePackageActions CreateUpdatePackageInAllProjects(
			PackageReference packageReference,
			IPackageManagementSolution solution,
			IPackageRepository sourceRepository)
		{
			PackageReferencePassedToCreateUpdatePackageInAllProjects = packageReference;
			SolutionPassedToCreateUpdatePackageInAllProjects = solution;
			SourceRepositoryPassedToCreateUpdatePackageInAllProjects = sourceRepository;
			return FakeUpdatePackageInAllProjects;
		}
コード例 #11
0
		void Run (string packageId, string packageVersion)
		{
			var packageReference = new PackageReference (
				packageId,
				new SemanticVersion (packageVersion),
				null,
				null,
				false);

			var node = new PackageReferenceNode (packageReference, true);

			reinstaller.Run (node);
		}
コード例 #12
0
		public PackageReferenceNode (
			PackageReference packageReference,
			bool installed,
			bool pending = false,
			IPackageName updatedPackage = null)
		{
			PackageReference = packageReference;
			Installed = installed;
			IsInstallPending = pending;

			UpdatedVersion = GetUpdatedPackageVersion (updatedPackage);
			IsReinstallNeeded = packageReference.RequireReinstallation;
		}
コード例 #13
0
		void Run (string packageId, string packageVersion)
		{
			var packageReference = new PackageReference (
				packageId,
				new SemanticVersion (packageVersion),
				null,
				null,
				false);

			var parentNode = new TestableProjectPackagesFolderNode (project.FakeDotNetProject, null);
			var node = new PackageReferenceNode (parentNode, packageReference, true);

			reinstaller.Run (node);
		}
コード例 #14
0
        public bool TryFindLatestPackageById(string id, out SemanticVersion latestVersion)
        {
            PackageReference reference = (from r in this.GetPackageReferences(id)
                                          orderby r.Version descending
                                          select r).FirstOrDefault <PackageReference>();

            if (reference == null)
            {
                latestVersion = null;
                return(false);
            }
            latestVersion = reference.Version;
            return(true);
        }
コード例 #15
0
        public bool TryFindLatestPackageById(string id, out SemanticVersion latestVersion)
        {
            PackageReference reference = GetPackageReferences(id).OrderByDescending(r => r.Version)
                                         .FirstOrDefault();

            if (reference == null)
            {
                latestVersion = null;
                return(false);
            }
            else
            {
                latestVersion = reference.Version;
                Debug.Assert(latestVersion != null);
                return(true);
            }
        }
コード例 #16
0
        public bool TryFindLatestPackageById(string id, bool includePrerelease, out IPackage package)
        {
            IEnumerable <PackageReference> references = GetPackageReferences(id);

            if (!includePrerelease)
            {
                references = references.Where(r => String.IsNullOrEmpty(r.Version.SpecialVersion));
            }

            PackageReference reference = references.OrderByDescending(r => r.Version).FirstOrDefault();

            if (reference != null)
            {
                package = GetPackage(reference);
                return(true);
            }
            else
            {
                package = null;
                return(false);
            }
        }
コード例 #17
0
        public bool TryFindLatestPackageById(string id, bool includePrerelease, out IPackage package)
        {
            IEnumerable <PackageReference> packageReferences = this.GetPackageReferences(id);

            if (!includePrerelease)
            {
                packageReferences = from r in packageReferences
                                    where string.IsNullOrEmpty(r.Version.SpecialVersion)
                                    select r;
            }
            PackageReference reference = (from r in packageReferences
                                          orderby r.Version descending
                                          select r).FirstOrDefault <PackageReference>();

            if (reference != null)
            {
                package = this.GetPackage(reference);
                return(true);
            }
            package = null;
            return(false);
        }
コード例 #18
0
 private static bool IsValidReference(PackageReference reference)
 {
     return(!String.IsNullOrEmpty(reference.Id) && reference.Version != null);
 }
コード例 #19
0
		public bool IsRestored (PackageReference packageReference)
		{
			if (packageReference.Version == null) {
				return false;
			}

			return CreateLocalPackageRepository ()
				.GetPackageLookupPaths (packageReference.Id, packageReference.Version)
				.Any ();
		}
コード例 #20
0
 public void AddFakePackageReference(string packageId, string version)
 {
     var packageReference = new PackageReference(packageId, new SemanticVersion(version), null, null, false, false);
     FakePackageReferences.Add(packageReference);
 }
コード例 #21
0
		public void DeleteEntry(string id, Version version)
		{
			var packageReference = new PackageReference(id, version, null);
			EntriesDeleted.Add(packageReference);
		}
コード例 #22
0
		bool IsPackageInstalled (PackageReference packageReference)
		{
			return projectManager.LocalRepository.Exists (packageReference.Id, packageReference.Version);
		}
コード例 #23
0
        public IVersionSpec GetConstraint(string packageId)
        {
            PackageReference packageReference = this.GetPackageReference(packageId);

            return(packageReference?.VersionConstraint);
        }
コード例 #24
0
		protected override bool IsPackageInstalled (PackageReference reference)
		{
			return PackageReferencesWithPackageInstalled.Contains (reference);
		}
コード例 #25
0
		void AddFileToLocalRepositoryLookupPath (PackageReference packageReference, string filePath)
		{
			filePath = filePath.ToNativePath ();
			var packageName = new PackageName (packageReference.Id, packageReference.Version);
			repository.LocalPackageRepository.AddPackageLookupPath (packageName, filePath);
		}
コード例 #26
0
 private static bool IsValidReference(PackageReference reference)
 {
     return !String.IsNullOrEmpty(reference.Id) && reference.Version != null;
 }
コード例 #27
0
 private IPackage GetPackage(PackageReference reference)
 {
     if (IsValidReference(reference))
     {
         return SourceRepository.FindPackage(reference.Id, reference.Version);
     }
     return null;
 }
コード例 #28
0
		PackageReferenceNode CreatePackageReferenceNode (PackageReference reference, UpdatedPackagesInProject updatedPackages)
		{
			return new PackageReferenceNode (
				reference,
				IsPackageInstalled (reference),
				false,
				updatedPackages.GetUpdatedPackage (reference.Id));
		}
コード例 #29
0
 private IPackage GetPackage(PackageReference reference) =>
 (!IsValidReference(reference) ? null : this.SourceRepository.FindPackage(reference.Id, reference.Version));
コード例 #30
0
		protected virtual bool IsPackageInstalled (PackageReference reference)
		{
			return reference.IsPackageInstalled (project.DotNetProject);
		}
コード例 #31
0
        public FrameworkName GetPackageTargetFramework(string packageId)
        {
            PackageReference packageReference = this.GetPackageReference(packageId);

            return(packageReference?.TargetFramework);
        }
コード例 #32
0
		void PackageIsInstalledInProject (PackageReference packageReference)
		{
			packagesFolderNode.PackageReferencesWithPackageInstalled.Add (packageReference);
		}
コード例 #33
0
 private static bool IsValidReference(PackageReference reference) =>
 (!string.IsNullOrEmpty(reference.Id) && (reference.Version != null));
コード例 #34
0
		public PackageReference AddPackageReference (string packageId, string packageVersion)
		{
			var packageReference = new PackageReference (
				packageId,
				new SemanticVersion (packageVersion),
				null,
				null,
				false,
				false);

			PackageReferences.Add (packageReference);

			return packageReference;
		}
コード例 #35
0
		void LogPackageAlreadyRestored (PackageReference packageReference)
		{
			logger.Log (MessageLevel.Debug, GettextCatalog.GetString ("Skipping '{0}' because it is already restored.", packageReference));
		}
コード例 #36
0
		public PackageReferenceNode (PackageReference packageReference, bool installed, bool pending = false)
		{
			PackageReference = packageReference;
			Installed = installed;
			IsInstallPending = pending;
		}
コード例 #37
0
		void AddPackageReference(string packageId, string version)
		{
			var packageReference = new PackageReference(packageId, new Version(version), null);
			packageReferences.Add(packageReference);
		}
コード例 #38
0
 public void DeleteEntry(string id, SemanticVersion version)
 {
     var packageReference = new PackageReference(id, version, null, null, false, false);
     EntriesDeleted.Add(packageReference);
 }
コード例 #39
0
		bool IsPackageRestored (PackageReference packageReference)
		{
			return SolutionPackageRepository.IsRestored (packageReference);
		}