c# - 我如何在 Git 中处理 Visual Studio 解决方案和项目文件?

标签 c# git visual-studio workflow versioning

我通常使用 Git 进行版本控制来处理 .NET。在我的团队中,我们并行工作,我们经常提交代码以集成到应用程序中。一切都很好,但 Visual Studio 的解决方案和项目文件。我们找到了两种方法:

  1. 永远不要提交那些文件,每个人都有自己的
  2. 在版本系统中包含这些文件

这两种方式各有利弊,但基本上每次我们从中央 repo 中提取数据时都会遇到困难。这里有一些我们发现的备用问题:(在括号中,引用上面的列表)

  • 我们必须在项目中包含其他人的文件 (1) 或包含我们最新的文件 (2)
  • 如果我们在不同的架构 (x86/x64) 上工作,我们必须手动更改 .csproj 文件 (2)
  • 针对引用和 NuGet 包回复了相同的问题

等等。 是否有适合我使用的工作流程?

最佳答案

提交 .sln.csproj 文件通常是最佳实践(如 this answer 中所示),但 merge 需要一些注意。
参见“Why are my .csproj files getting messed up after a git rebase?”。

*.csproj -text merge=union(见下文)
*.sln -text merge=unionv

或者您可以放弃 .csproj 并在本地重新生成它们 as in this tweet .
忽略这些 csproj 文件的另一个原因是它们是否重新生成,如 in this context

yellowblood当与 merge=union 策略一起使用时,警告 ( in the comments ) 关于 csproj 文件的严重冲突问题。
这与文章“Merge conflicts in csproj files”相呼应。
这就是为什么有一个 suggestion for VS IDE should support file patterns in project files (为了在添加符合该模式的新.cs 文件时修改.csproj 文件)。

It's been suggested that if Visual Studio sorted its elements first, that would help mitigate the problem.
That helps reduce the incidental conflicts caused by Visual Studio's apparent non-deterministic sort of elements.
But it doesn't make the issue of merge conflicts go away.

关于c# - 我如何在 Git 中处理 Visual Studio 解决方案和项目文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21511959/

相关文章:

c# - 日、月、日、年的日期格式

c# - 为什么不能使用 = 运算符设置 DbContextOptions?

git - 从没有提交历史记录的另一个分支创建分支

c++ - Visual Studio 2015 C++ 编译时卡住计算机直到编译完成

c# - UWP 与 ITextRange 接口(interface)的使用。 WPF 中的 TextRange 对象

c# - 如何在具有一个数据库的两个系统上连接C#应用程序,两个应用程序是相同的

Git - 对文件进行了本地更改,但需要从远程存储库取回原始副本?

ruby-on-rails - 我应该将 Rails 4 bin/目录添加到 git 吗?

visual-studio - 如何在批处理文件中找到最新的 Visual Studio 开发人员命令提示符?

c - 为什么我的编译器(VS2017)选择 'CALL-JMP' 来到达子例程而不是仅仅 'CALL' ?