30

I am pulling my hair out with trying to get tfIgnore to work in Visual Studio 2013.

I followed the instructions here: bottom of this article and excluded my packages file like this:

\folderA\folderB\packages 

The path looks fine and is what Visual Studio generated for me. I have checked the file in to the place where Visual Studio generated it and tried rebuilding but the packages all still appear in my included changes folder in pending changes.

I've tried all sorts of other combinations of file locations and filespec commands but it never seems to do anything.

Am I missing something obvious?

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
davy
  • 4,474
  • 10
  • 48
  • 71
  • I've given up with .tfignore and packages (I think something is broken), I just cloak the folder instead, – DaveShaw May 01 '14 at 21:08
  • See an answer here http://stackoverflow.com/questions/24143925/get-tfs-to-ignore-my-packages-folder/24211160#24211160 – Just TFS Jul 10 '14 at 10:05
  • Is your folder already stored in Source Control? If you accidentally checked in a folder and then created an ignore file, the files will still show up in pending changes until you have removed the files from source control. – Wouter de Kort Aug 10 '14 at 20:02
  • See also this question, I've made some comments to the answer by MrHinsh http://stackoverflow.com/questions/26604506/tfs-vs-2013-ignore-all-nuget-packages/26618439#26618439 - basically, TFVS and NuGet don't play nice together. – DaveShaw Dec 04 '14 at 20:57

6 Answers6

17

A bug in NuGet may be causing the problem. This is the workaround:

  1. Create a .nuget folder in your solution folder, if it doesn't exist.

  2. In the .nuget folder, create a file nuget.config with this content:

<configuration>
    <solution>
        <add key="disableSourceControlIntegration" value="true" />
    </solution>
</configuration>
Edward Brey
  • 40,302
  • 20
  • 199
  • 253
11

I noticed that if you have one file checked in the packages folder, for example repositories.config then the .tfignore pattern doesn't work.

My solution was to delete the packages folder from source control entirely, then the packages content were successfully ignored

Edward Wilde
  • 25,967
  • 8
  • 55
  • 64
  • 8
    Exactly - tfignore only deals with newly added files (and folders). If you specify a folder to ignore but the folder exists, it (and its children) is not ignored. – Edward Thomson Aug 21 '14 at 12:59
  • 13
    I keep deleting the packages folder in TFS (local workspace), committing that deletion, and I always have `\*\packages` ignored, but the damn `packages\repositories.config` keeps getting added back to TFS! It's got a little `+` sign in Source Control Explorer again now. Like I'm pregnant! – Jason Kleban Aug 22 '14 at 14:07
9

In pending changes, right click the root package folder -> click undo. You should see your changes move to the "Detected changes" dialog box, under excluded changes (the window where you can promote files into source control).

Now, open up .tfignore and simply add packages. You should see that now, when you open detected changes, your packages aren't displayed.

Michael Fry
  • 1,090
  • 9
  • 12
  • 5
    This seems to kind of work, but when I get my package files restored via NuGet Package Restore (triggered when building the solution), the files in `packages` get added right to "included changes" anyway. – Doctor Blue Feb 02 '15 at 17:46
  • 1
    Thanks, needed to undo on the packages folder – Chris Marisic Sep 10 '15 at 19:04
4

I had the same issue. I went and found that there is a bug in the NuGet client:

Ignore Files

Note: There is currently a known bug in the NuGet Client that causes the client to still add the packages folder to version control. A workaround is to disable the source control integration. In order to do that, you'll need a nuget.config file in the .nuget folder that is parallel to your solution. If this folder doesn't exist yet, you'll need to create it. In nuget.config, add the following content:

http://docs.nuget.org/consume/package-restore/team-build

And I was able to get it working by following the work around linked in the "Ignore Files" section above. Here is a snippet of the work around below:

Respect .tfignore and .gitignore files for TFS Integration description

When using TFS integration in Visual Studio, NuGet will pend adds to the /packages folder even when there is a .tfignore or .gitignore file in place that says to ignore the /packages folder. NuGet should respect the ignore file rather than requiring that the user create a NuGet.config file that has disableSourceControlIntegration=true.

This can be done by calling into the LocalItemExclusionEvaluator: http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.localitemexclusionevaluator.aspx

Before adding items to TFS, we should check this evaluator. We should at least do it for the /packages folder if nothing else.

https://nuget.codeplex.com/workitem/4072

4

If the file or folder(s) you want to ignore changes to are checked-in to TFS, then ignoring them in .tfignore won't do anything - you have to remove them from source control first. That way any changes to them will be ignored.

Matty J
  • 3,116
  • 32
  • 31
1

Looks like someone called "aheidebrecht" is trying to provide a NuGet package to keep NuGet packages from checking into TFS. Seems a bit perverted...

In package manager console run...

PM> Install-Package DisableSourceControlIntegration-TFS -Version 1.0.1 

https://www.nuget.org/packages/DisableSourceControlIntegration-TFS

barrypicker
  • 9,740
  • 11
  • 65
  • 79