对于C#开发工作项目结构 [英] Project Structure for C# Development Effort

查看:93
本文介绍了对于C#开发工作项目结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么目录/解决方案/项目结构,你觉得是最易于管理,便于介质用C#编写大的项目?通过中大我的意思是项目,其中包括与嵌套的命名空间层次结构中的多样化的Visual Studio C#项目类型。 1



我在视窗部分发现,在Visual Studio 2008中的项目类型主要感兴趣的是:Windows窗体,WPF,自定义控件为和类库。此外,我使用的MSBuild(通过Visual Studio中)来构建我的项目。



我从来没有发现由Visual Studio自动生成的默认结构,值得使用。这种结构具有仅仅一个文件夹为含有溶液和嵌套文件夹的每个项目。我不知道这是不是因为我在过去使用C#项目的规模(中小)的。这是否有结构较大的项目有什么好处?你有没有发现它有用吗?



我也有兴趣的东西像文件夹名称和其命名空间的关系。



以下是我对项目结构的个人目标。



目标




  • 每个项目应该相当自足。也就是说,我宁愿要能够逐个检查每一个出来,编译它(凡依赖允许的)。

  • 导航结构应该很容易。

  • 目录结构应该映射到一个明确的和直接的方式命名空间。

  • 确定解决方案文件应该很容易。

  • 项目应至多在Visual Studio(的MSBuild)很少或根本没有额外的努力或层次结构的各个层次建立




    1. 请注意这里我所说的'项目'的意思,除非明确指出发展的努力。



解决方案

我目前使用的是结构,其中整个系统被分成逻辑部分,每部分为一个单独的Visual Studio解决方案。每一个这样的解决方案包含在一个文件夹结构看起来像这样:

  [逻辑部分名称] 
| -doc $ b $ C | -lib
| - //溶液中的
由项目所需的任何非GAC组件| -src
| - 生产
| | -Project1
| | -Project2
| -Tests
| -UnittestProject1
| -UnittestProject2
| -tools
| - //需要自动构建和这种$ B $任何工具b //(NUnit的,NCover,MSBuild任务,...)

这确实需要一些走动文件(从由另一个需要引用的一个逻辑部分输出被移动到其它部分的lib文件夹,例如),但是这可以很容易地一个MSBuild脚本内实现自动化。我们也有这样一个MSBuild脚本调用,以便每个逻辑部分中的所述的MSBuild脚本,并且输出移动到相应的lib文件夹。这样我可以建立我与一步到位当前工作的逻辑部分,也使整个系统的构建与点击(或,好了,双击)。



我们已经使用该结构在当前项目的最后一年半左右的时间,它似乎摸出相当好。


What directory/solution/project structure do you find to be the most manageable and convenient for medium to large projects written in C#? By "medium to large" I mean projects which include a diverse set of Visual Studio C# project types in a hierarchical structure with nested namespaces.1

I'm primarily interested in those project types found in the 'Windows' section in Visual Studio 2008: Windows Forms, WPF, Custom Controls for both and Class Libraries. Additionally, I'm using MSBuild (via Visual Studio) to build my project.

I've never found the default structure automatically generated by Visual Studio to be worth using. This structure has one folder solely for containing the solution and a nested folder for each project. I'm wondering if this is because of the scale of project I've used C# for in the past (small to medium). What benefits does this structure have for larger projects? Have you found it useful?

I'm also interested in things like folder names and their relation to namespaces.

The following are my personal goals for project structure.

Goals

  • Each project should be reasonably self-contained. That is, I'd prefer to be able to check each one out individually and compile it (where permitted by dependencies).
  • Navigating the structure should be easy.
  • Directory structures should map to namespaces in a clear and straightforward way.
  • Identifying solution files should be easy.
  • Projects should build with little or no extra effort in Visual Studio (MSBuild) at most or all levels of the heirarchy

    1. Please note that my use of the word 'projects' here means 'development efforts' except where explicitly noted.

解决方案

I currently use a structure where the whole system is split into logical parts, each part being a separate Visual Studio solution. Each such solution is contained in a folder structure looking like this:

[logical part name]
  |-doc
  |-lib
     |- // any non-GAC-assemblies needed by the projects in the solution
  |-src
     |-Production
     |  |-Project1
     |  |-Project2
     |-Tests
        |-UnittestProject1
        |-UnittestProject2
  |-tools
     |- // any tools needed for automated builds and such 
        // (NUnit, NCover, MSBuild tasks, ...)

This does require some moving around of files (output from one logical part that is referenced by another needs to be moved into that other part's lib folder, for instance) but this can easily be automated within an MSBuild script. We also have such an MSBuild script that calls the MSBuild scripts of each of the logical parts in order, and moves the output into the appropriate lib folders. This way I can build the logical part that I am currently working with in one step, and also make a build of the full system with one click (or, well, double click).

We have used that structure in the current project for the last year and a half or so, and it seems to work out rather well.

这篇关于对于C#开发工作项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆