30
votes

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?

6
I've given up with .tfignore and packages (I think something is broken), I just cloak the folder instead,DaveShaw
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♦
See also this question, I've made some comments to the answer by MrHinsh stackoverflow.com/questions/26604506/… - basically, TFVS and NuGet don't play nice together.DaveShaw

6 Answers

17
votes

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>
11
votes

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

9
votes

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.

4
votes

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
votes

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.

1
votes

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