Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstallPackageAsync not using DependencyBehavior #5479

Open
ReinoutW opened this issue Jun 23, 2017 · 1 comment
Open

InstallPackageAsync not using DependencyBehavior #5479

ReinoutW opened this issue Jun 23, 2017 · 1 comment
Labels
Functionality:SDK The NuGet client packages published to nuget.org Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug
Milestone

Comments

@ReinoutW
Copy link

ReinoutW commented Jun 23, 2017

When installing a package through the NuGet api, the DependencyBehavior doesn't seem to be applied on dependent packages.

On our private NuGet repository, we have a component with the following version numbers:

  • 3.0.0-a0637958946
  • 3.0.0-a0638256777
  • 3.0.0-a0638871234

Another component has a dependency on this component, but always installs pre-release version 3.0.0-a0637958946 instead of using the highest version (or highest patch version).

We might do something wrong, but we can't find it.

        public async Task<PackageIdentity> InstallPackage(string packageId, string packageVersion, bool includePrerelease = true)
        {
            PackageIdentity identity = new PackageIdentity(packageId, NuGetVersion.Parse(packageVersion));
            if (identity != null && identity.HasVersion)
            {
                List<Lazy<INuGetResourceProvider>> resourceProviders = CreateResourceProviders();

                NuGetPackageManager packageManager = InitializeNuGetPackageManager(resourceProviders);

                ResolutionContext resolutionContext = new ResolutionContext(DependencyBehavior.Highest, includePrerelease, false, VersionConstraints.None);
                INuGetProjectContext projectContext = new ProjectContext();

                IEnumerable<SourceRepository> sourceRepositories = new List<SourceRepository>
                {
                    new SourceRepository(_packageSource, resourceProviders)
                };

                await packageManager.InstallPackageAsync(packageManager.PackagesFolderNuGetProject, identity, resolutionContext, projectContext, sourceRepositories,
                     Array.Empty<SourceRepository>(), CancellationToken.None);
            }
            return identity;
        }

@mishra14
Copy link
Contributor

@ReinoutW are you still facing this issue?

@mishra14 mishra14 added this to the Backlog milestone Dec 19, 2017
@nkolev92 nkolev92 added Functionality:SDK The NuGet client packages published to nuget.org and removed NuGet API labels Apr 24, 2020
@zivkan zivkan added Priority:2 Issues for the current backlog. Type:Bug labels Nov 17, 2020
@nkolev92 nkolev92 added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. and removed Priority:2 Issues for the current backlog. labels Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:SDK The NuGet client packages published to nuget.org Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests

6 participants