我应该对哪些 C# 项目文件进行版本控制?
我有一个项目希望通过 perforce 版本控制手动管理,因为我只有 Express 版本。我正在寻找的是哪些文件应该被排除在版本控制中,因为锁定许多文件可能会导致 Visual Studio 编译和调试出现问题。
到目前为止,我所拥有的都包括在内。
.cs 文件(属性文件夹除外)
.resx 文件
.csproj 文件
排除
bin 文件夹
obj 文件夹
属性文件夹
.user 文件
让我知道是否应该包含更多我已排除的内容,或者是否有更好的方法来执行此操作。
I have a project I'm looking to manually manage via perforce version control as I only have the Express edition. What I'm looking for is which files should be excluded in the version control as locking many of the files can result in a problem for visual studio compiling and debugging.
What I have, so far, included.
.cs files (except properties folder)
.resx files
.csproj files
Excluded
bin folder
obj folder
Properties folder
.user file
Let me know if there is something more that should be included that I have excluded or if there is a better way to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该包含 Properties 文件夹;它包含 AssemblyInfo.cs(包含所有程序集属性)以及项目的默认资源和设置文件(如果有)。
您还应该包含 .sln 文件(如果有)。
You should include the Properties folder; it contains AssemblyInfo.cs (with all of the assembly attributes) and the project's default Resources and Settings files, if any.
You should also include the .sln file, if any.
还要排除:
Re: app.config:
app.config
通常包含计算机特定信息(例如数据库连接字符串、默认设置或资源路径),而您不包含每次你从源代码管理中签出时都希望这个被破坏。这些文件应该使用部署脚本创建/复制。当一个项目中有多个开发人员,每个开发人员都有自己的数据库服务器时,这尤其令人烦恼。相反的情况可能会更加危险 - 如果您通过从修订控制中签出来将代码部署到生产中,您可能会无意中将生产设置为使用开发数据库,这可能是灾难性的。
更新 2019-03
我已经开始依赖这里的
.gitignore
建议,因为无论我正在处理什么类型的项目,它似乎都能完美工作:https://github.com/github/gitignore/blob/master/VisualStudio.gitignore截至 2019-03-01,它看起来像这样:
Also exclude:
Re: app.config:
app.config
usually contains machine specific info (like database connection strings, default settings, or paths to resources) and you don't want this clobbered everytime you check out from source control. These files should be created/copied with deploy scripts.When there are multiple developers on a project each with their own database server, this is especially annoying. The reverse can be even more dangerous - if you deploy code to production by checking out from revision control, you may inadvertently set production to use a development database, which could be disastrous.
Update 2019-03
I have started to rely on the
.gitignore
suggestions here, as it seems to work perfectly regardless of the type of project I am working on: https://github.com/github/gitignore/blob/master/VisualStudio.gitignoreAs of 2019-03-01 it looks like this:
不要忘记添加您可能在应用程序中使用的任何图像、图标等。很容易忘记这些。
另外,如果您有与项目相关的任何文档 - 规格、设计、帮助文件等,请将它们放入项目下的单独文件夹中,然后也将它们包含在内。
Don't forget to add any images, icons etc. you might be using in your application. It's easy to forget these.
Also if you have any documentation associated with the project - specifications, designs, help files etc. Put these into separate folders under the project and then include them too.
如果我使用第三方 DLL,我会通过项目对它们进行版本控制,并使用并行部署,以便在编译期间将 DLL 复制到 bin 文件夹(而不是仅在 GAC 中注册 DLL)。这样做的效果是另一个开发人员可以从源代码控制中拉取项目,并拥有成功编译和运行项目所需的依赖项。没有浪费地下载和安装第三方组件,并且您确信每个人都在针对相同版本的第三方 dll 进行开发/测试。
If I am using third party DLLs I version control them with the project, and use side-by-side deployment such that the DLL is copied to the bin folder during compilation(as opposed to just registering the DLL in the GAC). The effect of this is another developer can pull the project down from source control and have the dependencies they need to successfully compile and run the project. There is no wasteful downloading and installing of third party components, and you are sure everyone is developing/testing against the same version of the third party dll.