如何防止 VS2015 NuGet 添加包到 TFS
How to keep VS2015 NuGet from adding packages to TFS
VS2013 有一个错误,NuGet 会将包添加为待定更改,即使您告诉它不要使用 .tfignore
。有一个 workaround,但它不适用于 VS2015/NuGet3,NuGet 又回到了它的老把戏。有 "Nu" 解决方法吗? :-)
Microsoft Connect 项目:NuGet adds packages to TFS despite .tfignore
我也遇到了同样的问题,还没找到真正的解决办法
到目前为止我找到的唯一解决方法是:
- 右键单击 "Team Explorer - Pending Changes" 中的包文件夹
和 select "undo".
看起来这已在 NuGet Visual Studio 2015 扩展的 version 3.2 RC 中修复 - 更新到此版本至少对我有用。
关于这个问题的讨论可以在 here 中找到,建议从 NuGet 3.1 更新到 3.2 RC。
更新
扩展的 3.2 版现已发布(已找到 here),其中包含此修复程序。
澄清
要实现此功能,您需要两件事:
- 包含
disableSourceControlIntegration
设置的 nuget.config
文件
- 符合
disableSourceControlIntegration
设置的 NuGet Visual Studio 2015 扩展版本(从 3.2 开始的版本应该可以工作)
如docs所示:
NuGet first loads NuGet.config from the default location, then loads any file named NuGet.config starting from the root of the current drive and ending in the current directory.
这意味着您可以在 default config file 中为您的用户配置文件(在 %APPDATA%\NuGet\NuGet.Config
中找到)或在解决方案目录中的 NuGet 配置文件中指定 <solution><add key="disableSourceControlIntegration" value="true" /></solution>
,例如,\MySolution\.NuGet\NuGet.config
.
在您的 %AppData%\NuGet\NuGet.Config
文件中,在 </configuration>
XML 标记之前添加以下内容...
<config>
<add key="repositoryPath" value="C:\NuGetPackages" />
</config>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
...您可以指定任何您想要的路径 - 重要的是将它放在 TFS 工作区之外!
现在您再也不用担心那些事情了。您的解决方案文件夹将不再包含任何包;所有解决方案都将默认使用您的自定义包位置。
注意 - 此作品基于 per-user。
直到现在,我一直在以 one-config-per-solution (\.nuget\NuGet.Config
) 的方式做同样的事情。感谢@dsghi 的见解!
确保您的解决方案文件夹不包含 .nuget
文件夹(旧的处理方式)。即使该文件夹未包含在解决方案中并且仅包含在文件系统中,它也会覆盖所有内容!
VS2013 有一个错误,NuGet 会将包添加为待定更改,即使您告诉它不要使用 .tfignore
。有一个 workaround,但它不适用于 VS2015/NuGet3,NuGet 又回到了它的老把戏。有 "Nu" 解决方法吗? :-)
Microsoft Connect 项目:NuGet adds packages to TFS despite .tfignore
我也遇到了同样的问题,还没找到真正的解决办法
到目前为止我找到的唯一解决方法是:
- 右键单击 "Team Explorer - Pending Changes" 中的包文件夹 和 select "undo".
看起来这已在 NuGet Visual Studio 2015 扩展的 version 3.2 RC 中修复 - 更新到此版本至少对我有用。
关于这个问题的讨论可以在 here 中找到,建议从 NuGet 3.1 更新到 3.2 RC。
更新
扩展的 3.2 版现已发布(已找到 here),其中包含此修复程序。
澄清
要实现此功能,您需要两件事:
- 包含
disableSourceControlIntegration
设置的nuget.config
文件 - 符合
disableSourceControlIntegration
设置的 NuGet Visual Studio 2015 扩展版本(从 3.2 开始的版本应该可以工作)
如docs所示:
NuGet first loads NuGet.config from the default location, then loads any file named NuGet.config starting from the root of the current drive and ending in the current directory.
这意味着您可以在 default config file 中为您的用户配置文件(在 %APPDATA%\NuGet\NuGet.Config
中找到)或在解决方案目录中的 NuGet 配置文件中指定 <solution><add key="disableSourceControlIntegration" value="true" /></solution>
,例如,\MySolution\.NuGet\NuGet.config
.
在您的 %AppData%\NuGet\NuGet.Config
文件中,在 </configuration>
XML 标记之前添加以下内容...
<config>
<add key="repositoryPath" value="C:\NuGetPackages" />
</config>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
...您可以指定任何您想要的路径 - 重要的是将它放在 TFS 工作区之外!
现在您再也不用担心那些事情了。您的解决方案文件夹将不再包含任何包;所有解决方案都将默认使用您的自定义包位置。
注意 - 此作品基于 per-user。
直到现在,我一直在以 one-config-per-solution (\.nuget\NuGet.Config
) 的方式做同样的事情。感谢@dsghi 的见解!
确保您的解决方案文件夹不包含 .nuget
文件夹(旧的处理方式)。即使该文件夹未包含在解决方案中并且仅包含在文件系统中,它也会覆盖所有内容!