如何让 visual studio 2013 源代码控制忽略包目录

How to get visual studio 2013 source control to ignore the packages directory

我正在使用 nuget 自动还原(较新版本,不是 MSBuild 集成还原)。当我构建我的解决方案时,所有依赖项都会被下载,但是,visual studio 总是将包目录添加到源代码管理(我使用的是 TFS)。我已经尝试更新 .tfignore 文件并添加一个 .nuget/NuGet.config with <add key="disableSourceControlIntegration" value="true" />。但似乎没有任何效果。如何让 visual studio 和 tfs 忽略包目录?

解决方案是右键单击该解决方案,然后单击 "Enable NuGet Package Restore"。

然后将以下内容添加到.tfignore:

\packages*

编辑: 我最初遵循 instructions here for auto restore but was unsuccessful. Then I enabled Nuget Package Restore as described above. This worked, but is a deprecated feature (as noted by @Daniel Mann). Finally, I followed the instructions here for migrating to auto restore 现在一切正常。我不知道这是否是正确的程序,但它对我有用。