简体   繁体   中英

How control what depenent version is installed when using PackageReference

I have a C# project that uses PackageReference to manage dependencies using NuGet. I am able to install top-level packages using the NuGet manager with no issues. However, I am looking for a way to force Nuget to install a specific version of one of the dependencies.

For example, I have a project called MainProject.Data. . In this project, I installed a package called XYZ.Main . But, XYZ.Main package has XYZ.Secondary >= 2.1.0 listed as dependency. I want a way to be able to force Nuget to install XYZ.Secondary 2.1.5 , not the latest which is XYZ.Secondary 2.1.25

How can I control which dependency to install?

How control what depenent version is installed when using PackageReference

I am afraid you cannot install the specific dependency 2.1.5 version when you install XYZ.Main package by PackageReference at the same time.

When you install the nuget package, it will automatically install the smallest version of the dependencies within the allowable range by default. It is designed by that.

As a suggestion ,

To install the XYZ.Secondary 2.1.5 , you should search dependency XYZ.Secondary on Nuget Package Manager UI and then update it to 2.1.5 . It will update the related version in your project to 2.1.5 .

Like this:

在此处输入图像描述

Besides , if you still want your requirements be implemented, you could suggest a feature on ourUser Voice Forum (click Suggest a Feature ). The Team will consider your request carefully and hope they will give you a satisfactory reply.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM