ricksmt
ricksmt

Reputation: 899

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.)

Upvotes: 5

Views: 1614

Answers (2)

CodeWizard
CodeWizard

Reputation: 142632

You should add it to your .gitignore file.

You have this repository :
https://github.com/github/gitignore

Which is the official git repository for the ignored files for many platforms and languages.

You can also use this site to generate the file for you:

enter image description here

Upvotes: 1

Jonathan.Brink
Jonathan.Brink

Reputation: 25443

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.

Upvotes: 2

Related Questions