visual-studio 你把你的第 3 方图书馆放在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3897635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:34:57  来源:igfitidea点击:

Where do you put your 3rd party libraries?

c#.netvisual-studio

提问by mpen

I've got a bunch of .dllassemblies, such as HtmlAgilityPackand MoreLinq. Where am I supposed to put these files? I usually toss them somewhere in my Projectsfolder, but then I'm always digging around for them. Is there a standard place to put them?

我有一堆.dll程序集,例如HtmlAgilityPackand MoreLinq。我应该把这些文件放在哪里?我通常把它们扔在我Projects文件夹中的某个地方,但后来我总是在四处寻找它们。是否有放置它们的标准位置?

回答by Patrick Karcher

There's no standardplace to put them, but make sure you:

没有放置它们的标准位置,但请确保您:

  • Put them in one place
  • Include them in source control.
  • 将它们放在一处
  • 将它们包含在源代码管理中。

I put all my required dll's in a top level directory in my solution called "Dependencies", parallel to the project folders. I have them in source control such that when new developers check out the solution, it all compiles and works right off. It's the only way to go.

我将所有需要的 dll 放在我的解决方案中名为“Dependencies”的顶级目录中,与项目文件夹平行。我将它们放在源代码管理中,这样当新开发人员检查解决方案时,它都会编译并立即运行。这是唯一的出路。

I include only the .dll files absolutely needed. This keeps it light, which is good, but then when I find some otherpart of MVC Contrib or whatever that I need, I have to go find the unzipped directory, which might not even be on my computer! Others put entire library directories (readme.txt and all) as part of their source control linked to the solution. This ensures you and future developers will have everything they need, but adds a little dead weight. Either is a good strategy.

我只包含绝对需要的 .dll 文件。这使它保持轻便,这很好,但是当我找到MVC Contrib 的其他部分或我需要的任何东西时,我必须去找到解压缩的目录,它甚至可能不在我的电脑上!其他人将整个库目录(readme.txt 和所有)作为链接到解决方案的源代码控制的一部分。这确保您和未来的开发人员将拥有他们需要的一切,但会增加一些负担。两者都是一个很好的策略。

回答by IanT8

Having a "Lib" folder at the same level as source projects is a common way.

将“Lib”文件夹与源项目处于同一级别是一种常见的方式。

To be honest, it's not the dependencies my projects have that I find hard to manage, it's the dependencies the dependencies have. I'd just like to mention NHibernate, Castle Windsor and the various Castle Windsor Facilities in particular. Getting all of those to play together on my last project cost me a lot of time.

老实说,我觉得难以管理的并不是我的项目所具有的依赖项,而是依赖项所具有的依赖项。我只想特别提一下 NHibernate、Castle Windsor 和各种 Castle Windsor 设施。在我的上一个项目中让所有这些人一起玩花了我很多时间。

For open source projects, I also like to have the source code handy because sometimes its useful to debug into the source code. (And sometimes because the documentation is so poor, you have to read the source code to find out how it works). I've seen VS projects arranged so that the project references the DLL yet at the same time, VS knows where to find the source code, as I write I can't quite remember how to do that.

对于开源项目,我也喜欢手边有源代码,因为有时调试源代码很有用。(有时因为文档太差,你必须阅读源代码才能了解它是如何工作的)。我已经看到 VS 项目的安排,以便该项目同时引用 DLL,VS 知道在哪里可以找到源代码,因为我写的我不太记得如何做到这一点。

So, a Lib folder for DLLs works for me; I often call it "Shared Dependencies".

因此,DLL 的 Lib 文件夹对我有用;我经常称之为“共享依赖”。

As for open-source source code, I don't have a standard way to version that because each project is structured differently and has a different build process. I don't like to tinker with the open-source project structure or build method because then, I take responsibility for it. If for some reason, it won't build, or builds incorrectly, or produces a faulty DLL, the cause would be exceedingly difficult to track down, and I'd have to get deep into troubleshooting all of that which I dont care about at all.

至于开源代码,我没有标准的版本方法,因为每个项目的结构不同,构建过程也不同。我不喜欢修补开源项目的结构或构建方法,因为那样的话,我要为此负责。如果由于某种原因,它不会构建,或者构建不正确,或者生成一个错误的 DLL,那么原因将非常难以追查,我必须深入解决所有我不关心的问题全部。

回答by Ian Mercer

In a folder UNDER your solution directory, e.g. "external" or "library". That way your continuous integration system (or other team members) can do a pull of one root from your source control system and have everything they need.

在您的解决方案目录下的文件夹中,例如“外部”或“库”。这样你的持续集成系统(或其他团队成员)可以从你的源代码控制系统中提取一个根并拥有他们需要的一切。

In SVN, use svn:externals to pull that directory from a different root so you can easily share library DLLS (and library projects) between solutions.

在 SVN 中,使用 svn:externals 从不同的根目录中提取该目录,以便您可以轻松地在解决方案之间共享库 DLLS(和库项目)。

回答by George Handlin

In the office we have a share on the network for referenced asseblies. These could be 3rd party or assemblies of our own that could be shared between projects.

在办公室,我们在网络上共享参考组件。这些可以是我们自己的第 3 方或程序集,可以在项目之间共享。

I also, don't like the idea of putting the dll files in source control. If all the developers have access to the share all will work fine.

我也不喜欢将 dll 文件放在源代码管理中的想法。如果所有开发人员都可以访问共享,那么一切都会正常工作。

回答by Jonathan Williams

I don't have a hard and fast rule on the location. However, I would encourage consistency!

我对位置没有硬性规定。但是,我会鼓励一致性

For example, I needed to to this for a small tool I'm writing for a client at the moment, so I checked their other code bases in Bitbucket which seemed to use a dependenciesfolder in the solution folder (alongside the other projects), so I copied that.

例如,我现在需要为一个客户编写一个小工具,所以我检查了他们在 Bitbucket 中的其他代码库,这些代码库似乎使用了解决方案文件夹中的依赖项文件夹(与其他项目一起),所以我复制了那个。

回答by Jeff Mercado

The visual studio directory in My Documentsseems like a logical place to put them. I don't know if it's thebest or anything wrong with it but at least all the libraries are found in one place.

Visual Studio 目录My Documents似乎是放置它们的合乎逻辑的地方。我不知道这是否是它最好还是什么错,但至少所有的库都在一个地方找到。

%USERPROFILE%\My Documents\Visual Studio XXXX\Libraries

回答by Jeff Mercado

At my company we place all our shared DLL assemblies onto a network drive in a folder called Assemblies. From there, we use SyncToyto mirror changes between that folder and a folder on our local development machines (in my case C:\Assemblies with subfolders for different versions or useful third party assemblies). Using the "Reference Paths" feature of Visual Studio projects makes it very easy to select different assembly versions based only on locations.

在我的公司,我们将所有共享的 DLL 程序集放在名为 Assemblies 的文件夹中的网络驱动器上。从那里,我们使用SyncToy来镜像该文件夹和我们本地开发机器上的文件夹之间的更改(在我的情况下,C:\Assemblies 带有用于不同版本或有用的第三方程序集的子文件夹)。使用 Visual Studio 项目的“参考路径”功能可以非常轻松地仅根据位置选择不同的程序集版本。

For projects at home, I would definitely go with the idea mentioned by Jeff M of placing them in the Visual Studio folder under My Documents.

对于家里的项目,我肯定会同意 Jeff M 提到的将它们放在My Documents.