gitignore and nuget

https://www.gitignore.io/

  • Super useful!

 

I recently ran into an issue – after downloading my c# project from github, i could not build the project. basically on compilation, the project was complaining saying there were missing references and such.

  • When i opened nuget manager, it showed the packages were all installed.
  • The packages folder was present.

It seemed the problem was because VS was assuming that the packages are there, so it was avoiding downloading the packages again. However, the content inside the ‘packages’ folder was not complete – aka .dlls were missing from the packages folder because there had been git-ignored.

It seems I had not done the gitignore properly !  In the references below, there is an example of how to gitignore VS projects properly.

<snip>

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

</snip>

 

References: