Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Exclude NuGet Content from Source Control

I know that NuGet packages (at least nowadays) should not be included in version control. How should I exclude files a package adds to my project?

For example: I have a .NET MVC project that uses the bootstrap NuGet package. It adds some CSS, JS, and font files to Content, Scripts, and fonts, respectively. Should these files be included in my source control? If not, what would be the best way to ignore them? (I'm using GIT on this particular project.)

like image 799
ricksmt Avatar asked Oct 19 '22 18:10

ricksmt


1 Answers

Generally speaking, generated files should not be tracked by your source control tool. Here is a good question that addresses pros/cons of doing so.

You can ignore those files and directories by creating a .gitignore file at the root of your repo.

Following your example package above, you could ignore that content by adding this to your .gitignore file:

Content
Scripts
fonts

Here is some more documentation on ignoring files with Git with .gitignore.

You can also populate your .gitignore based on what the VisualStudio project uses.

like image 97
Jonathan.Brink Avatar answered Nov 01 '22 09:11

Jonathan.Brink