简体   繁体   English

应该从源代码管理中排除哪些.net文件?

[英]What .net files should be excluded from source control?

应该从源代码管理中排除.net应用程序的哪些文件扩展名?为什么还要?

Depends on the project, but I've got the following for a Silverlight + WPF project in my .gitignore: 取决于项目,但我的.gitignore中的Silverlight + WPF项目有以下内容:

# Visual Studio left-overs
*.suo        # 'user' settings like 'which file is open in Visual Studio'
*.ncb        # Used for debugging
*.user
*.ccscc      # Used for versioning
*.cache

# Editor left-overs
*~           # (x)emacs
*.bak        # Windows related
\#*\#        # (x)emacs
*.orig       # Own usage

# Compiled files
*/bin/
*/obj/
*/Obj/       # git is case sensitive
*/Generated_Code/
PrecompiledWeb
*/ClientBin
# Windows left-overs
Thumbs.db    # Having images in the source tree generates those files in Explorer

However, the '.suo' is somewhat problematic: it also contains 'user' settings which should have been project settings, like the startup page for a Silverlight application. 但是,'。suo'有些问题:它还包含应该是项目设置的“用户”设置,例如Silverlight应用程序的启动页面。

The best and only way is to iteratively add the files to exclude. 最好也是唯一的方法是迭代添加要排除的文件。 If you're using git, using git-gui to quickly and interactively see the list of files which you've forgotten to exclude. 如果您正在使用git,请使用git-gui快速,交互地查看您忘记排除的文件列表。 Adapt .gitignore and refresh in git-gui. 适应.gitignore并在git-gui中刷新。 Iterate until the files left over are the ones you typed in. 迭代直到剩下的文件是你输入的文件。

Some types of files are not quite clear up front. 某些类型的文件预先不太清楚。 Be sure you understand all the files you check in. For example, for the RIA services in our Silverlight project we had an authentication database generated by Visual Studio which contained 2 accounts and resulted in a hefty 10Mb .MDB database file(!). 确保您了解您签入的所有文件。例如,对于我们Silverlight项目中的RIA服务,我们有一个由Visual Studio生成的身份验证数据库,其中包含2个帐户,并生成了一个巨大的10Mb .MDB数据库文件(!)。 Once we understood where it came from, changing it to an SQL dump reduced the size to a (still hefty) 500Kb. 一旦我们了解它的来源,将其更改为SQL转储就会将大小减小到(仍然很大)500Kb。 Constantly (re)checking prior to the checkin itself is always required, so no list is definite. 总是需要在签到之前不断(重新)检查,因此没有明确的列表。

It really depends on your build system. 这真的取决于你的构建系统。 Check in the minimum files you need to run a full build. 检查运行完整版本所需的最少文件。

Generally, this means you exclude everything except your csproj, and *.cs files. 通常,这意味着您排除除csproj和* .cs文件之外的所有内容。 You can probably check in your .sln file if you want. 如果需要,您可以签入.sln文件。

I got my list from this question: Best general SVN Ignore Pattern? 我从这个问题得到了我的列表: 最好的一般SVN忽略模式?

Like any 'list', be sure you look over the exclusions and make sure all of them fit/don't fit your needs, but it is a great start. 与任何“列表”一样,请务必查看排除项并确保所有这些排除项都符合您的需求,但这是一个很好的开始。

Here is a list of minimum entries I use in recent .NET projects. 这是我在最近的.NET项目中使用的最小条目列表。

*.vs
*.user
*.cache
bin/
obj/
  • First entry omits the hidden folder .vs and its contents. 第一个条目省略了隐藏文件夹.vs及其内容。
  • Last two omits anything under those folders. 最后两个省略了这些文件夹下的任何内容

Feel free to add a comment in case of a down-vote. 如果投票不足,请随意添加评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM