简体   繁体   中英

Automating .net framework package installation: resolving package dependency on other packages

Long story short : I am trying to automate package .net framework nuget updates in a solution via VS2019 package manager console and i can't get a package dependencies on other packages (Though i know the data is available because you can see it in the UI).

Long story long : I am trying to automate nuget installation for .net framework and i chose to use the package manager console in visual studio (If there is a preferred option i would love to hear about it). The problem i am trying to solve is this: Problem input: Package A : version 1, has dependency on package B version > 1. version 2 has a dependency on package B version > 2. Package B : version 1. version 2 has a breaking change. Package C : version 1, has dependency on package B version > 1.

Problem I am trying to solve : I have these 3 packages referenced by the same project. I want to upgrade package A to version 2. Its dependency is package B version > 2. Running package A update to version 2 (via package manager UI or console) will update package B to version 2. Boom! - package C will detect it is missing a method it requires from B version 1 only at runtime!

What i am trying to do - Scripting the installation process prompting the user for these type of dependencies.

My problem - For that i want to get a package dependencies and i can't find the way to do it using the package manager console.

Appreciate some help :)

For that i want to get a package dependencies and i can't find the way to do it using the package manager console.

We cannot use nuget manage console to get the package dependencies.In addition to UI viewing nuget package dependencies, we can get the dependencies from csproj file in the nuget project A. This is the related content in A.csproj file:

<ItemGroup>
        <PackageReference Include="Antlr">
          <Version>3.5.0.2</Version>
        </PackageReference>
        <PackageReference Include="Microsoft.Extensions.Logging">
          <Version>3.0.0</Version>
        </PackageReference>
</ItemGroup>

Another is that you can view package dependencies is through the nuspec file which is created by command nuget spec ( if you use nuspec files to enforce dependencies ), which are the documentation you use before packaging the project.

Scripting the installation process prompting the user for these type of dependencies.

Note: In view of your situation, you cannot use two versions of the nuget package in the same project which will cause version conflict.

Suggestions :

  1. I wonder why you deleted the method required by C when you upgrade B. Basically, when we upgrade and modify the package, we will new features to it without removing the original data and methods to prevent references to other dependent packages in the project from using the corresponding methods. So you could restore the methods required by the C package in the Package B version two.

  2. If you make a major change to package B version2 and the steps of restoring the method are a bit complicated, I suggest you can make a copy of package B specifically for C packages. Just rename the Package B version 1 and referenced by Package C to distinguish it from the second version of the B package .

Hope it could help you.

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