Friday, December 18, 2015

Prevent packages folder from being added to Team Foundation Version Control in Visual Studio 2015

Solutions built with Visual Studio 2015 uses NuGet Automatic Package Restore instead of MSBuild-integrated package restore. At least for me this made Visual Studio want to check in the package folder into Team Foundation Version Control.

To prevent the packages folder from being added to Team Foundation Version Control in Visual Studio 2015 you can add a .nuget folder in your solution folder. In the .nuget folder add a file named NuGet.config with the following content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
</configuration>

This tells Nuget to not even call Visual Studio about the changes to the packages folder.

For TFS 2012 and later also add a .tfignore file in your solution folder with the following content:

## Ignore the NuGet packages folder in the root of the repository
packages

#include package target files which may be required for msbuild
!packages/*.targets

This will ignore changes to the packages folder.

Sources

No comments: