April 14, 2005

Project Structure for .NET applications

Over the last few months I have been working more and more with .NET (C# specifically). After working almost exclusively on Java projects for the last several years I have a bias for how a project should be laid out. However, I quickly realized that a Java projects structure does not translate easily to .NET. This seems specifically related to the nuances of Visual Studios.

I initially started investigating the different layouts for several popular .NET open source projects. Each project I looked at varied greatly in how it was laid out.
I was surprised to see that no common approach existed for .NET projects.

The following is a quick overview of how I have structured projects. I'll use PicoContainer as an example:

Java Project Structure

-- picocontainer
-- lib
-- src
-- java
-- org
-- picocontainer
-- defaults ...
-- test
-- org
-- picocontainer
-- defaults ...

.NET Project Structure

-- picocontainer
-- lib
-- src
-- PicoContainer
-- Defaults ...
-- PicoContainer.Tests
-- Defaults ...


The main difference is how package naming in Java does not translate easily to namespaces in .NET. The folders PicoContainer and PicoContainer.Tests are each separate Assemblies. PicoContainer.Tests of course contains a reference to PicoContainer. The differences are of course minor but from what I have seen there does not yet seem to be a standard project structure for .NET.

The advantage of the .NET layout is it works well with Visual Studios and does not require any tweaking of the project properties. Hacking the properties just makes things confusing and less intuitive.