Visual Studio解决方案中的文件夹或项目?[英] Folders or Projects in a Visual Studio Solution?

本文是小编为大家收集整理的关于Visual Studio解决方案中的文件夹或项目?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。





  • 您将获得单个组件(无需额外的 ILMerge 体操)
  • 更容易混淆(因为您将拥有更少的公共类型和方法,最好完全没有)


  • 有一些源代码部分是项目的一部分,但默认情况下或根本不可部署(单元测试、额外插件等)
  • 涉及更多开发人员,您希望将他们的工作视为可消耗的黑匣子.(不太推荐)
  • 如果您可以清楚地将您的项目分成独立的层/模块,并且您想确保它们不能交叉使用 internal 成员.(也不推荐,因为您需要决定哪个方面最重要)




When spliting a solution in to logical layers, when is it best to use a separate project over just grouping by a folder?


By default, always just create new folder within the same project

  • You will get single assembly (without additional ILMerge gymnastic)
  • Easier to obfuscate (because you will have less public types and methods, ideally none at all)

Separating your source code into multiple projects makes only sense if you...

  • Have some portions of the source code that are part of the project but not deployable by default or at all (unit tests, extra plugins etc.)
  • More developers involved and you want to treat their work as consumable black box. (not very recommended)
  • If you can clearly separate your project into isolated layers/modules and you want to make sure that they can't cross-consume internal members. (also not recommended because you will need to decide which aspect is the most important)

If you think that some portions of your source code could be reusable, still don't create it as a new project. Just wait until you will really want to reuse it in another solution and isolate it out of original project as needed. Programming is not a lego, reusing is usually very difficult and often won't happen as planned.