Jack Ryan
Jack Ryan

Reputation: 8472

Best way to configure build directory structure for a windows application

I am writing a small application at the moment and am trying to organise my build output to be a little closer to the finished product. The application is made up of a number of different projects. There is a core library that contains most of the functionality, a GUI app and a command line app that both reference the Core Dll, and a number of Plugin Dlls that are loaded at runtime and implement different data sources, these all reference core.dll, these also may include some other third party dlls. There are also a number of peripheral files such as a readme. And finally the core.dll and the datasource plugins are unit tested.

I would like to configure my build so that everything is output into directories as I would expect it to be when installed. I want debug and release builds to be built into different directories but otherwise have the same directory structure. I only want tests to be built for debug builds, and want them to be runnable, but seperated (I guess all test dlls would get output into a seperate directory). Here is how I imagine the structure will be.

Code/
    solutions etc here
Debug/

    Project.Core.dll
    Project.Gui.exe
    Project.Cli.exe
    readme.txt
    lib/
        ThirdParty1.dll
        ThirdParty2.dll
    DataSource/
        DataSource1.dll
        DataSource2.dll
    Tests/
        Project.Core.Tests.dll
        DataSource1.Tests.dll
Release/
    same as Debug but without tests.

Is there any way of getting a solution to build like this? I'm beginning to think it will be difficult to build the plugins and the app all from one solution, and probably not even wise, but as they will all be distributed together it would be nice. I am open to using Nant or another build tool if that will make it simpler.

Upvotes: 2

Views: 1630

Answers (2)

Plebsori
Plebsori

Reputation: 1085

Modifying each project every time you create a new one is annoying.

Here's the solution:

  1. Locate the real vs project, it'll be somewhere under ("%programfiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates*")

  2. Copy it locally somewhere.

  3. Extract it.

  4. Edit the contents making changes that better suit your project layout style. Make sure you update the project name, the name is what you see when looking for the project in the new project dialogue box. It's xml tag is Name, you'll find it in the {something}.vstemplate file.

  5. Compress the content again. (Note: the contents must NOT be in a sub folder, so /* and NOT /{somefolder}/*).

  6. Place your custom project under ("%USERPROFILE%\Documents\Visual Studio 2010\Templates\ProjectTemplates*").

  7. Add a new project is Visual Studio, selecting your custom one, and enjoy!

Upvotes: 0

Juozas Kontvainis
Juozas Kontvainis

Reputation: 9597

It is possible. Just modify OutputPath tag manually in each .csproj in both Debug and Release file to something like this

<OutputPath>..\$(Configuration)\any_subdirs</OutputPath>

You can disable tests building for Release using Configuration manager.

Upvotes: 1

Related Questions