简体   繁体   English

如何在一个解决方案中共享源项目之间的许多二进制文件?

[英]How to share many binary files between source projects in one solution?

I have a smallish solution, with about under twenty projects. 我有一个小的解决方案,大约有不到20个项目。 The solution used to also contain about six source projects written by a third party service provider, ACME. 该解决方案过去还包含由第三方服务提供商ACME编写的大约六个源项目。 Now, finally, this other party is supplying us only with a handful of DLLs. 现在,最后,这个对方向我们提供了一些DLL。 I used to just included their source, one project per DLL, in the solution, and so I am looking for a neat way to include all these assemblies in the solution, so they can be referenced from the many projects that need them. 我过去只是在解决方案中包含了他们的源代码,每个DLL的一个项目,所以我正在寻找一种巧妙的方法将所有这些程序集包含在解决方案中,因此可以从需要它们的许多项目中引用它们。

My immediately apparent options are: 我立即明显的选择是:

  1. Create an AcmeAssembly project, add all DLLs as project items set to copy to output. 创建一个AcmeAssembly项目,将所有DLL添加为要复制到输出的项目项。
  2. Create an AcmeAssembly solution folder. 创建AcmeAssembly解决方案文件夹。 Quicker and simpler than a 'binary-only' source project, but solution folders have the very, very large drawback of having no means of grouping the files without a solution file, ie outside of VS. 比“仅二进制”源项目更快更简单,但是解决方案文件夹具有非常大的缺点,即无法在没有解决方案文件的情况下对文件进行分组,即在VS之外。
  3. Create a NuGet package that includes all the required binaries. 创建一个包含所有必需二进制文件的NuGet包。 Then at least we also have a partly 'phycical' grouping in the packages folders. 那么至少我们在packages文件夹中也有一个部分“phycical”分组。 My problem here is I have never written a NuGet package, but I am not asking how to here. 我的问题是我从来没有写过NuGet包,但我不是在问这里怎么样。 I am asking about three candidate solutions, and more will be welcome, and if NuGet wins, I get to learn to write a package. 我问三个候选解决方案,欢迎更多,如果NuGet获胜,我会学习写一个包。

I can't simply use the project's output bin\\debug and bin\\release folders. 我不能简单地使用项目的输出bin\\debugbin\\release文件夹。 To me, these are strictly output folders, and nothing but other dependency assemblies should also be output there. 对我来说,这些是严格的输出文件夹,除此之外,还应该输出其他依赖程序集。 Deleting the bin folder should have absolutely zero effect on a build, so that is certainly no place to store binaries. 删除bin文件夹应该对构建产生绝对零影响,因此当然不能存储二进制文件。

Create your Acme library folder (something like: C:\\Source\\Library\\AcmeLibrary). 创建您的Acme库文件夹(类似于:C:\\ Source \\ Library \\ AcmeLibrary)。 Put all of your Acme dll's in that folder. 将所有Acme dll放在该文件夹中。 Then create the Solution Folder in VS and add the existing items to it (don't add the folder, but the items in the C:\\Source\\Library\\AcmeLibrary folder to the solution folder using "Add Existing Item..." menu selection). 然后在VS中创建解决方案文件夹并将现有项添加到它(不要使用“添加现有项...”菜单将文件夹,但C:\\ Source \\ Library \\ AcmeLibrary文件夹中的项目添加到解决方案文件夹中选择)。

The advantages of nuget over the other solutions are: nuget优于其他解决方案的优势是:

  1. Support for versioning 支持版本控制
  2. Support is built in into Visual Studio and MSBuild 支持内置于Visual Studio和MSBuild中
  3. No 'magic folders' that all developers need to have on their machines 没有所有开发人员需要在他们的机器上拥有的“魔术文件夹”

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM