First published on MSDN on Sep 21, 2016
Normally, it is a best practice to not include the bin folder of your solution to source control, in TFS; However, there is an exception to this, when it comes to building websites with team build.
When building a website with TFS build (vNext and XAML), and the Bin folder is not added to source control explorer, you might receive several assembly missing exceptions. These might also include nuget packages that are added to the solution. The package restore might happen successfully, but the build would still fail to find the references.
Website projects, unlike other project types, doesn’t have a csproj file, which includes the relative path to the assembly references. Instead, this is added in the dll.refresh files, which are part of the Bin folder.
Hence, if the complete Bin folder is removed from source control, the build process will not know where to look for the referenced assemblies during build.
To avoid getting in to this issue, we should be adding the Bin folder, just with the .refresh files, to source control, for the website. (The actual dll’s are not needed, just the .refresh files.) The procedure to include the refresh files depends on the version control system you are using:
Bin folder and the dlls will by default be excluded, during the check-in. Explicitly include the Bin folder with the .refresh files, while checking in the solution.
Bin folder and the contents will be by default ignored, in the .gitignore file. In this case we will have to modify the .gitignore file in the repo, to allow Bin folder, and only the .refresh files within it, to be committed.