16

We had a contractor visit recently who questioned our methodology of structuring projects. Please note that I am specifically referring to the directory structure. He suggested using the Microsoft guidelines. I thought I would be able to Google "Microsoft guidelines .NET project directory structure" and find something helpful, however this has proven not to be the case. As it stands we do something like this:

[Company.System.Feature]
  |-doc
     |Sandcastle project
  |-lib
     |Nuget packages
  |-src
    |-Project1 e.g. web
    |-Project2 e.g. business logic
    |-UnittestProject1
    |-Specs

The doc folder contains a Sandcastle solution like what is described here: https://www.codeproject.com/Articles/15176/Sandcastle-Help-File-Builder (see: absolute and relative paths). Therefore the doc folder contains a Help folder, which contains the generated help file. The lib folder contains all Nuget packages.

Are there any Microsoft guidelines, which recommend how to structure a solution? I have looked here: https://stackoverflow.com/questions/789389/project-structure-for-c-sharp-development-effort/789554?noredirect=1#comment86756309_789554 amongst other places. Most of the articles and questions I have read seem to be created 2007-2009. I believe Nuget was introduced in 2010. Are there any Microsoft guidelines? I read about something called Tree Surgeon, however this does not seem to exist anymore: https://archive.codeplex.com/?p=treesurgeon.

I am using TFS; Cruise Control and DDD is that makes any difference.

  • 4
    Directory structures are very much a matter of taste. Use the folder structure that most clearly states your project/organizations intentions. – Robert Harvey Apr 17 '18 at 14:49
  • 5
    Also, the next time someone says you should be following "Microsoft Guidelines" about something, ask said person to provide those guidelines, or show you where you can find them. Otherwise, it's useless advice. – Robert Harvey Apr 17 '18 at 14:51
  • 2
    the odd bit is putting nuget packages in lib instead of packages – Ewan Apr 17 '18 at 15:23
  • 1
    @Ewan, nuget packages don't even belong in packages any more, for dotnetcore and VS2017-style projects. They now live in the projects' obj directories. – David Arno Apr 17 '18 at 15:58
  • 2
    pff! upgrading?!?!? sounds like it might break stuff – Ewan Apr 17 '18 at 16:08
19

On MSDN, there are some very old official guidelines. These are out of date though. As the page says, "This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies." So I'd recommend you avoid these guidelines.

There was an attempt to define a common solution structure via Project Scaffold. This is more orientated toward F# though, rather than C#. It didn't really take off though and there's little sign of development of the ideas these days.

The most active and up to date set of guidelines is maintained by David Fowler, who is a developer at Microsoft on the ASP.NET team. These guidelines are used by many within Microsoft, including the Roslyn (the C# and VB.Net compiler) teams. You could do far worse than adopt that approach therefore.

  • I saw the first two links, but not the third. +1 for the third link. Would I put my entire Sandcastle project in the docs folder or just the Help files that are generated by the Sandcastle project? Not sure why this answer was downvoted. – w0051977 Apr 17 '18 at 14:14
  • 1
    To be fair, every page that isn't included in Microsoft's new documentation system is stamped with the words "this content is outdated and no longer being maintained." That doesn't mean there isn't some useful information there. – Robert Harvey Apr 17 '18 at 14:53
  • Were would you put the Specs? In the Tests folder or in a directory called Specs (in the same directory as the src folder)? I guess it doesn't really matter too much. – w0051977 Apr 22 '18 at 13:57
  • @RobertHarvey: Fair enough, but referring to that page alone with nothing further to back it up is also not a reason to change the project folder structure if a different one has already been established. – Flater May 7 '18 at 13:30
  • You can see David Fowlers guidelines in practice at most of the open source projects at GitHub, eg Enity Framework. – pfx May 26 '18 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.