I have recently noticed a lot of questions about ignoring the packages folder when using Team Foundation Server Version control. I read a lot of solutions but none seemed to work for me. Then I realized I needed a little bit of information from all the solutions to get it to work. In this post I will explain exactly how I got TFVC to ignore my packages folder.
At the solution level create a folder named .nuget. You have to create this folder from Source Control Explorer in Visual Studio because you cannot create a folder the begins with a period in Windows Explorer.
- Open Source Control Explorer
- Navigate to the folder with your .sln file
- Right-click the background
- Select New Folder
- Name the folder .nuget
Create a file named nuget.config in the .nuget folder.
- Select File / New / File…
- Select XML File
- Click Open
- Copy and paste the text below into the file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
- Press Ctrl+S
- Navigate to the .nuget folder
- Name the file nuget.config
- Click Save
Now we need to create the .tfignore file at the solution level.
- Right-click on the solution
- Select Add / New Item…
- Select Text File
- Name the file .tfignore
- Copy and paste the text below into the file:
packages
- Save all the files
- Check both .tfignore and nuget.config files into source control
- Close Visual Studio
Now you can restart Visual Studio and open your solution. Now when you add NuGet packages they will not be added to source control. I also recorded a video for this that you can view below.