When you add a nuget package to a project it puts the assemblies in a /packages folder at the solution level.
将nuget包添加到项目时,它会将程序集放在解决方案级别的/ packages文件夹中。
I know that there are ways to change this, but I'm wondering why this is the default location, as it seems very unhelpful for these reasons:
我知道有办法改变这个,但我想知道为什么这是默认位置,因为这些原因似乎非常无益:
1) If you have a project that is part of multiple solutions, the /packages folder won't necessarily be where you the project expects it.
1)如果您的项目是多个解决方案的一部分,/ packages文件夹不一定是项目所期望的位置。
2) You are expected to manually check it into source control for other team members, which is much less convenient than if it was part of the project that needs it.
2)您需要手动将其检查为其他团队成员的源代码控制,这比它是需要它的项目的一部分要方便得多。
3) If you move the project somewhere else on the file system or to a different machine that doesn't have the full code base, it won't find the /packages folder where it expects to.
3)如果将项目移动到文件系统上的其他位置或者移动到没有完整代码库的其他计算机上,它将找不到它所期望的/ packages文件夹。
It seems all of these would be resolved if NuGet just used a /packages folder inside the project, not the solution. And that seems like a much more logical place to put packages that the project relies on anyway.
如果NuGet在项目中使用了/ packages文件夹而不是解决方案,似乎所有这些都将得到解决。这似乎是一个更合理的地方放置项目所依赖的包。
So... I'm assuming that there were/are some good reasons for doing it at the solution level, and I'm hoping someone can enlighten me.
所以...我假设在解决方案层面上有一些很好的理由,我希望有人可以启发我。
2 个解决方案
#1
4
You should have a read at this, that explains how to use nuget without commiting packages to your source control, and by side effect solve points 1 and 3 of your question : http://blog.davidebbo.com/2011/03/using-nuget-without-committing-packages.html
您应该阅读本文,其中解释了如何使用nuget而不将包提交到源代码控制,以及通过副作用解决问题的第1点和第3点:http://blog.davidebbo.com/2011/03/using -nuget-没有-犯-的packages.html
#2
2
I think it's to save disk space. If you had a large solution with 50 projects and you used a package in every one of those, you would end up with 50 copies of that package, binaries and all. Whereas keeping them at solution level is far more efficient in that respect.
我认为这是为了节省磁盘空间。如果你有一个包含50个项目的大型解决方案,并且你在每个项目中都使用了一个软件包,那么最终会得到50个软件包,二进制文件和所有项目。在这方面,将它们保持在解决方案级别会更有效率。
In terms of source control, you shouldn't be putting your actual packages folder in there. Just add the packages.config file and either do what David Ebbo suggests in the blog post mentioned by mathieu or create a simple batch file to download all your packages based on the packages.config files it can find.
在源代码控制方面,您不应该将实际的包文件夹放在那里。只需添加packages.config文件,或者执行David Ebbo在mathieu提到的博客文章中建议的内容,或创建一个简单的批处理文件,根据它可以找到的packages.config文件下载所有软件包。
It's not much effort to create your own company nuget feed, so you can keep your private packages in there.
创建自己的公司nuget feed并不费力,因此您可以将私人包保留在那里。
#1
4
You should have a read at this, that explains how to use nuget without commiting packages to your source control, and by side effect solve points 1 and 3 of your question : http://blog.davidebbo.com/2011/03/using-nuget-without-committing-packages.html
您应该阅读本文,其中解释了如何使用nuget而不将包提交到源代码控制,以及通过副作用解决问题的第1点和第3点:http://blog.davidebbo.com/2011/03/using -nuget-没有-犯-的packages.html
#2
2
I think it's to save disk space. If you had a large solution with 50 projects and you used a package in every one of those, you would end up with 50 copies of that package, binaries and all. Whereas keeping them at solution level is far more efficient in that respect.
我认为这是为了节省磁盘空间。如果你有一个包含50个项目的大型解决方案,并且你在每个项目中都使用了一个软件包,那么最终会得到50个软件包,二进制文件和所有项目。在这方面,将它们保持在解决方案级别会更有效率。
In terms of source control, you shouldn't be putting your actual packages folder in there. Just add the packages.config file and either do what David Ebbo suggests in the blog post mentioned by mathieu or create a simple batch file to download all your packages based on the packages.config files it can find.
在源代码控制方面,您不应该将实际的包文件夹放在那里。只需添加packages.config文件,或者执行David Ebbo在mathieu提到的博客文章中建议的内容,或创建一个简单的批处理文件,根据它可以找到的packages.config文件下载所有软件包。
It's not much effort to create your own company nuget feed, so you can keep your private packages in there.
创建自己的公司nuget feed并不费力,因此您可以将私人包保留在那里。