Should .nuget folder be added to version control?

2019-01-21 03:36发布

With newer versions of NuGet it is possible to configure a project to automatically restore NuGet packages so that the packages folder doesn't need to be included in the source code repository. Good.

However, this command adds a new .nuget folder and there is a binary there, NuGet.exe. This can also be re-created automatically by Visual Studio and so it doesn't feel correct to add that to version control. However, without this folder Visual Studio won't even load the solution properly.

How do you people deal with this? Add .nuget to source control? Run some command line script before opening the solution?

7条回答
The star\"
2楼-- · 2019-01-21 04:27

Although I usually don't like the idea of adding exe's to source control, I would suggest that source control should contain anything that is required in order to open, build and execute the project.

In this case it sounds like the .nuget folder is a required dependency. Therefore it ought to be under source control.

The only question left, that you need to research, is how NuGet is going to react if that folder is marked read-only, which TFS will do once it has been checked in.


Update: I did a little more research on this as I've never used NuGet before. http://blog.davidebbo.com/2011/03/using-nuget-without-committing-packages.html

I would suggest that probably what you want to do is make NuGet a requirement that has to be installed on every developers workstation.

Further, you should place in source control the batch file required to get a workstation ready to start editing the project. The batch file is going to run the commands necessary to get and install the dependency packages.

Beyond that I'd say you might want to contact NuGet directly to ask them how, exactly, this is supposed to work.

查看更多
登录 后发表回答