gpt4 book ai didi

c# - 嵌入 vs 引用我的依赖项 : Best practices for . NET/NuGet 包?

转载 作者:行者123 更新时间:2023-11-30 15:25:18 24 4
gpt4 key购买 nike

我以 NuGet 包的形式向公司内的客户提供 C#/.NET 类库。我的库依赖于其他一些第 3 方库(例如 Newtonsoft's excellent Json.NET )。

我假设 NuGet 的标准工作方式是我的包将只包含对我依赖的其他 NuGet 包的引用。当客户在他们的项目中安装我的 NuGet 包时,他们的 Developer Studio 将自动下载它们。

问题 #1:

Can I be certain that Developer Studio will download the versions of those NuGet packages that I was building against and not the 'latest' versions?

问题 #2:

Will it cause problems if their project also uses a 3rd-party library that I'm using (like Json.NET), especially if they are using a different version? Does this 'just work', or do I need to do something about this?

如果这在某处被阐明,我深表歉意,但我无法找到这些问题的具体答案。

最佳答案

Nuspec Reference 中清楚地列出了这一点

具体来说:

Specifying Dependencies

Starting from version 2.0, package dependencies can be specified to vary according to the framework profile of the target project. The element contains a set of elements. Each group contains zero or more element and a target framework attribute. All dependencies inside a group are installed together if the target framework is compatible with the project's framework profile.

  <dependencies> 
<group>
<dependency id="RouteMagic" version="1.1.0" />
</group>
<group targetFramework="net40">
<dependency id="jQuery" />
<dependency id="WebActivator" />
</group>
<group targetFramework="sl30">
</group>
</dependencies>

版本在哪里:

The range of versions acceptable as a dependency. Typically this is just a version number which represents a minimum version. However a more explicit version range syntax is supported.

(更新:更新对较新版本 nuget 的引用)

关于c# - 嵌入 vs 引用我的依赖项 : Best practices for . NET/NuGet 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31445182/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com