简体   繁体   English

自动化 .net 框架包安装:解决包对其他包的依赖

[英]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).长话短说:我正在尝试通过 VS2019 包管理器控制台在解决方案中自动化包 .net 框架 nuget 更新,但我无法获得对其他包的包依赖(尽管我知道数据可用,因为您可以在用户界面)。

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).说来话长长:我想对.NET框架自动化的NuGet安装,我选择使用Visual Studio中的包管理器控制台(如果有我会喜欢听到关于它的最佳选择)。 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.我试图解决的问题是:问题输入:包 A :版本 1,依赖包 B 版本 > 1。版本 2 依赖包B版本 > 2。包 B :版本 1。版本 2 有一个打破变化。 Package C : version 1, has dependency on package B version > 1.包 C :版本 1,依赖包 B 版本 > 1。

Problem I am trying to solve : I have these 3 packages referenced by the same project.我试图解决的问题:我有同一个项目引用的这 3 个包。 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!我想将包 A 升级到版本 2。它的依赖项是包 B 版本 > 2。运行包 A 更新到版本 2(通过包管理器 UI 或控制台)会将包 B 更新到版本 2。砰! - package C will detect it is missing a method it requires from B version 1 only at runtime! - 仅在运行时,包 C 将检测到它缺少 B 版本 1 所需的方法!

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:我们不能用的NuGet管理控制台来获取包dependencies.In除了UI观看NuGet包的依赖关系,我们可以得到的csproj文件的依赖关系中的NuGet项目A.这是A.csproj文件中的相关内容:

<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.另一个是您可以通过命令nuget spec创建的nuspec文件查看包依赖nuget spec如果您使用 nuspec 文件强制执行依赖项),这是您在打包项目之前使用的文档。

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.注意:针对你的情况,不能在同一个项目中使用两个版本的nuget包,会造成版本冲突。

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.不知道为什么你升级B的时候把C需要的方法删掉了。相应的方法。 So you could restore the methods required by the C package in the Package B version two.所以你可以在包B版本二中恢复C包需要的方法。

  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.如果你对包B version2进行了较大的改动,并且恢复方法的步骤有点复杂,建议你可以专门为C包制作一个包B的副本。 Just rename the Package B version 1 and referenced by Package C to distinguish it from the second version of the B package .只需重命名 Package B version 1 并由 Package C 引用,以将其与 B 包的第二个版本区分开来

Hope it could help you.希望能帮到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将.NET Framework程序包安装到PCL会尝试安装.NET Standard程序包 - Installing .NET Framework package to PCL attempts to install .NET Standard packages 解决 .NET 项目中的 package 依赖项 - Resolving package dependencies in a .NET project sqlite3.exe Nuget软件包安装失败-.NET Framework兼容性? - sqlite3.exe Nuget package installation failure - .NET framework compatibility? .nu​​spec 依赖版本和 packages.config 包版本如何相互关联? - How does .nuspec dependency version and packages.config package version relate to each other? 多目标NuGet程序包的错误依赖关系解决 - Erroneous dependency resolving for multi-targeting NuGet package 我是否可以使用不在.NET Framework上的旧版DLL创建NuGet包(或其他包)? - Can I create a NuGet package (or other package) with legacy dll's that are not on a .NET Framework? 用于ASP.Net Core和Full Framework项目的bootstrap.sass nuget软件包的不同安装 - Different installation for bootstrap.sass nuget package for ASP.Net Core and Full framework projects Nuget package 未安装 in.Net Framework - Nuget package not installing in .Net Framework 是否可以更改软件包管理器控制台的软件包安装目录? - It is possible to change packages installation directory for Package Manager Console? 解决nuget包引用 - Resolving nuget package references
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM