For a .Net project, what file extensions should I

2020-07-18 11:51发布

问题:

Everytime I start a project I have to think carefully about which files to exclude from source control. Has someone made a list of the criteria so I can look it up from the beginning? I work on my own so I have not got round to it. I appreciate that in the case of a DLL, you would want to include some and exclude others, so it is not just dependent on the file extension. My projects are ASP.Net, although a general discussion of other templates would also be useful.

回答1:

From http://blog.goneopen.com/2009/06/git-excludes-for-dotnet/:

.DS_Store
._*
TestResults
*Resharper*
**.ReSharper**
**\_ReSharper.**
*.bak
*.cache
*.resharperoptions
*.suo
*.user
*.vsprops
*/TestResults
*\bin*
*\obj*
_ReSharper.*


回答2:

If you use ReSharper, be sure to exclude _Resharper* folders

If you're using Subversion for source control then the VisualSVN Visual Studio plug-in will manage excludes for you automatically.

Be sure to include any third-party dlls that your project references that won't be in the GAC of your build or deployment machines. Our practice is to have a lib folder that all such dlls live in, and we add references to them from that folder. This ensures that the hintpath property in the csproj file is correct (it stores a relative path to the referenced dll).



回答3:

Do not sourcecontrol bin and obj folders, as well as *.suo and *.user (if you're using Visual Studio) files.

If you feel uneasy about keeping third-party DLLs in source control, try Componento, which, granted, does not yet have a sizable components database.



回答4:

As a general rule, only source control files which are required to build the application.



回答5:

Generic ingores from a project folder:

*.Cache
*.user
bin
obj

And from the solution (a level up)

*.cache
_PublishedWebSites
*.suo

We've also got the following - which are instance specific config settings referenced out of generic configs (i.e. web.config for asp.net apps)

AppSettings.config
Provider.config
connections.config

There are .config.sample files that are version controlled.

You should probably set bin, obj, *.cache, *.user and *.suo as global in your subversion setup - but as this is (if memory serves) machine specific you're probably going to end up doing explicit ignores anyway