嵌入 vs 引用我的依赖项:Best practices for .NET/NuGet package?
Embed vs reference my dependencies: Best practices for .NET/NuGet package?
我正在向我公司内的客户提供一个 C#/.NET class 库作为 NuGet 包。我的库依赖于其他一些第 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?
抱歉,如果这在某处被阐明,但我无法找到这些问题的具体答案。
中清楚地列出了这一点
具体来说:
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#/.NET class 库作为 NuGet 包。我的库依赖于其他一些第 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?
抱歉,如果这在某处被阐明,但我无法找到这些问题的具体答案。
具体来说:
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 的引用)