Monday, October 02, 2006

Enabling Sane Project and Solution Structure

One of the constant pains of Visual Studio 2005 and Visual SourceSafe is the strong tie between solution, file system, and VSS structures. If you only ever have a single large solution with all of your projects underneath it, this never becomes apparent. If, however, you have several core components that need to be shared across several distinct solutions (systems/applications/whatever), things get gross. Visual Studio likes the solution to be at a higher level in VSS and the file system than all the projects contained in it. Once you have a project that needs to be in more than one solution (i.e., have more than one parent folder), this is impossible. Ideally I'd like my file system to look something like:

c:\projects (all solution files live here)

with a similar VSS structure:
$/ (all solutions here)

Here's what I do when creating a new solution and project to make this work:

  1. Create a blank solution
    File->New Project
    Other Project Types/Visual Studio Solutions/Blank Solution

    Don't check "Add to Source Control"
    Location: c:\projects
    Name: whatever (application name)

  2. File System Surgery
    File->Save As...
    Delete the subdirectory under projects (should be c:\projects\whatever\)

  3. Add solution to VSS
    Right click on sln, Add to Source Control
    Leave name alone (will be whatever.root)
    Location $/

  4. VSS Surgery
    Start the VSS Client
    Drag and drop Whatever.sln and Whatever.vssscc from c:\projects into $\ in VSS
    In Visual Studio, go to File->Source Control->Change Source Control
    There should be line line listed that says "Solution: Whatever.sln"
    Click the elipsis ("...") in the Server Binding column
    Pick $/
    Hit Ok twice
    In VSS, right click on $/whatever.root and pick delete (check the box to destroy permanently)
    Close VSS

When adding new projects, always choose "C:\projects" for Location
When adding new websites, always choose "C:\projects\websites" for Location
and they will automatically be added to the right place in VSS

And that's it. Basically I change the binding root of the solution from the automatically created "whatever.root" folder to its parent, allowing multiple solutions to live in the same directory and in effect share the same binding root.

No comments: