Naming convention for Visual Studio solutions and projects

前端 未结 6 864
梦毁少年i
梦毁少年i 2021-02-06 21:33

We were thinking about organizing our BIG project this way:

\\trunk
  [CompanyName]
    [Product1]
        [Project1]
          CompanyName.Product1.Project1.csproj
          


        
相关标签:
6条回答
  • 2021-02-06 22:05

    That looks pretty good if you ask me. Especially naming your projects by their full name including full name space part. I've found this helpful when there are numerous projects, especially if there happens to be similar projects across different products.

    How and whether you split on product and project (where I assume project is more like an application than a solution project) is very much down to the size of your organisation, it's make-up and your preferences.

    0 讨论(0)
  • 2021-02-06 22:05

    Looks like taken from the school book. That's usually how my solutions get set up, and I have found it to work quite well over the years.

    0 讨论(0)
  • 2021-02-06 22:08

    With respect to file names - I prefer that my project file name match the output assembly name because it makes it much easier to know what produces what. Doing a directory listing is much faster than searching the csproj files in a tree for the one that produces the assembly I care about.

    I don't get worked up about solution files because they don't influence our build environment so I end up making my own to have the exact scope I want (and the specific per-solution items, like test metadata, that I want).

    With respect to folder structure - I don't worry too much if the folders leading down the project files match the namespaces. I want my code to sit on disk in a way that makes the most sense for the project. Sometimes this means the test code and product code are in sibling directories - sometimes it means they are much further apart. Sometimes there is a namespace that is contributed to by multiple teams (not advocating that design, just a reality) - but those teams want to life in their own folders for whatever reason.

    Don't forget the importance of version control branching strategies in your overall project design. The Company and Product boundaries may be branches and therefore would not necessarily need to represented as directories on disk.

    Don't let this be a source of analysis paralysis though. Make a reasonable choice. Use version control. You can always change later if you are wrong.

    0 讨论(0)
  • 2021-02-06 22:08

    I consider this is better

    \trunk
      [CompanyName]
        [Product1]
          CompanyName.Product1.sln
          [Main] --Optional
            CompanyName.Product1.csproj
          [Project1]
            CompanyName.Product1.Project1.csproj
          [Project2]
            CompanyName.Product1.Project2.csproj
        [Product2]
          CompanyName.Product2.sln
          [Main] --Optional
            CompanyName.Product2.csproj
          [Project1]
            CompanyName.Product2.Project3.csproj
          [Project2]
            CompanyName.Product2.Project2.csproj
          [Project3]
            CompanyName.Product2.Project2.csproj
    

    Why? Because when you get the code from repository you get, by example, "Product1" directory, it contains all you need to work. The [Main] directory contains the default base namespace, usually the exe or main project. It is optional.

    0 讨论(0)
  • 2021-02-06 22:09

    Looks good to me.

    It's a point to note that by default, the default namespace in a Visual Studio project is just the project name. Surely that indicates that naming your projects like your namespaces is "the Visual Studio Way".

    Solutions are most naturally named after the product/project. Like you indicate.

    0 讨论(0)
  • 2021-02-06 22:13

    An alternative that I've used is to have all my solution files in the same directory.

    \trunk
      [CompanyName]
        CompanyName.Product1.sln
        CompanyName.Product2.sln
        [Product1]
            [Project1]
              CompanyName.Product1.Project1.csproj
            [Project2]
              CompanyName.Product1.Project2.csproj
        [Product2]
            [Project3]
              CompanyName.Product2.Project3.csproj
    
    0 讨论(0)
提交回复
热议问题