Borek Bernard
Borek Bernard

Reputation: 53321

NuGet and version control - how to handle Contents folder

With newer versions of NuGet it is no longer necessary to version control the packages folder and it is pretty simple to add that to the .gitignore file.

However, certain NuGet packages also add files to the Contents folder and the question is how to handle that? I think that that files should also be git-ignored but is it practical to maintain possibly complex Contents exclude rules?

Upvotes: 3

Views: 300

Answers (1)

VonC
VonC

Reputation: 1325387

When you read the justification for "Enabling Using NuGet Without Checking In Packages Folder", it is about:

This new feature will make it so that if the packages folder (or any package folder within the packages folder) is missing, the packages folder (or missing package folder) will automatically be restored when compiling the application. This ensures that the application will compile even though the packages folder was missing at the time.

So basically what can be regenerated isn't versioned.
The general idea is that, if it cannot be easily regenerated or fetched, it should be versioned.

And it doesn't seem that what you put in Content is in that category, as illustrated by this example in the article "Creating a NuGet Package in 7 easy steps - Plus using NuGet to integrate ASP.NET MVC 3 into existing Web Forms applications ";

Step 2 - Add stuff to your Content Folder

Since I want my NuGet package to add stuff to folders in my target Web Application, I put whatever I want in a folder called Content. Anything in that will show up in the root of my target project. This can be CSS, JS, CS or VB files, whatever. These files will all get dropped onto the project your package is applied to.

Content folder

So versioning said Content might be advisable.

Upvotes: 3

Related Questions