packages.config 是否必须在项目文件夹中?

Does packages.config have to be in the project folder?

为了整理我的文件结构,我将 packages.config 移动到一个子文件夹。才发现它不再被 Nuget 拾取了。

是否可以移动文件或将其硬编码到VS中,使其必须与项目文件位于同一目录中?

谷歌搜索没有给我明显的答案,我只是得到关于 packages.config 目的的一般信息。

If used, packages.config is typically located in a project root. It's automatically created when the first NuGet operation is run, but can also be created manually before running any commands such as nuget restore.

本文来自 packages.config reference。尽管它声明配置文件通常位于 项目根目录中,但没有任何关于移动它的要求的指示。因此,它可能是 Visual Studio Nuget 包管理器的限制,它需要项目根目录中的 packages.config 文件。我从未见过任何官方文档或在不破坏包管理器的情况下移动此文件的工作示例。

Does packages.config have to be in the project folder?

您不能将该 packages.config 文件移动到项目根文件夹以外的任何其他子文件夹中。

此外,我同意 thatguy

Packages.config nuget management format 允许 packages.config 文件位于项目的根目录中,nuget 和 msbuild 将能够识别该文件并管理项目中的 nuget 包。 这就是它的机制。

所以我的建议是你应该把它移回项目的根目录。 到目前为止,这是确保你成功管理包的唯一方法 packages.config.

此外,如果您仍然希望您的请求成真,我建议您可以在我们的User Voice Forum(点击建议一个特征)。团队会认真考虑您的要求,希望能给您满意的答复。