How to keep VS2015 NuGet from adding packages to T

2019-01-16 12:09发布

VS2013 had a bug where NuGet would add packages as pending changes, even if you told it not to with .tfignore. There was a workaround, but it doesn't work with VS2015/NuGet3, and NuGet is back to its old tricks. Is there a "Nu" workaround? :-)

Microsoft Connect item: NuGet adds packages to TFS despite .tfignore

3条回答
时光不老,我们不散
2楼-- · 2019-01-16 12:48

It looks like this is fixed in version 3.2 RC of the NuGet Visual Studio 2015 Extension - updating to this version worked for me, at least.

A discussion about this issue can be found here where it is recommended to update from NuGet 3.1 to 3.2 RC.

Update

Version 3.2 of the extension has now been released (found here) which includes this fix.

Clarification

To get this working you need two things:

  1. A nuget.config file containing the disableSourceControlIntegration setting
  2. A version of the NuGet Visual Studio 2015 Extension that respects the disableSourceControlIntegration setting (versions from 3.2 onward should work)

As indicated in the 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.

This means that you can specify <solution><add key="disableSourceControlIntegration" value="true" /></solution> in the default config file for your user profile (found at %APPDATA%\NuGet\NuGet.Config) or in the NuGet config file in your solution directory, e.g., \MySolution\.NuGet\NuGet.config.

查看更多
冷血范
3楼-- · 2019-01-16 12:50

In your %AppData%\NuGet\NuGet.Config file, add the following just before the </configuration> XML tag...

<config>
  <add key="repositoryPath" value="C:\NuGetPackages" />
</config>
<solution>
  <add key="disableSourceControlIntegration" value="true" />
</solution>

...you can specify any path you want - the important thing is putting it OUTSIDE your TFS workspace!

Now you never have to worry about that stuff again. Your solution folder will not contain any packages anymore; all solutions will default to using your custom packages location instead.

NOTE - This works is on a per-user basis.

Until now, I've been doing the same in a one-config-per-solution (\.nuget\NuGet.Config) manner. Thanks to @dsghi for the insight!

Make sure your solution folder does not contain a .nuget folder (old way of doing things). Even if the folder is NOT included in the solution and only in the file system, it will override everything!

查看更多
冷血范
4楼-- · 2019-01-16 13:07

I have the same problem and I haven't found a real solution yet.

The only workaround I've found so far is:

  • Right click the packages folder in "Team Explorer - Pending Changes" and select "undo".
查看更多
登录 后发表回答