none
How can I setup up a common project that will need different dependencies based on a solution? RRS feed

  • Question

  • We have an application that runs on both web and desktop. The separate web and desktop solution includes a common business layer project.

    This common business layer project requires a reference to a dataset layer. We have two separate dataset layers. One uses SQL (for web) and one uses VistaDB (for desktop).

    The issue here, is that when building the web version, in the web solution, we have to change the reference in the business layer project to the SQL dataset project. Then, when we build the desktop version, in the desktop solution, we have to change the reference in the business layer project to the VistaDB dataset project.

    Is there a way we can setup these solutions and/or projects so that we don't have to constantly change the dataset reference in the common business layer project back and forth depending on what version we want to build?

    • Moved by Figo Fei Tuesday, March 23, 2010 8:37 AM (From:Getting Started With Visual Studio Team System)
    Monday, March 22, 2010 5:04 PM

All replies

  • Rather depends on how different the data access layer has to be for each option.

    Potentially, you could have a build option which copies a config file.  In this config file you have a connection string which points to the relevent database.

    Or the application uses some flag in the config file to choose which of 2 more complex connections it's going to use.

    Or have  2 projects with 2 dll exposing the same interface and work as a black box DAL.  Swop between these at compile time depending on build option.

    You can do loads with msbuild, people usually don't bother because it's unnecessary.

    You might also want to look at PRISM, there's likely something in there does this kind of thing.

    Tuesday, March 23, 2010 11:00 AM
  • I think dependency injection will help you out. If you don't know what that is: You tell the application within the appconfig what classes to create at runtime. With having two different appconfigs (for web and windows application), you can use two different data layers. It might be a bit over the top but it saves you any opportunities for later development and changes.

     

    Build 3 solutions or projects (depends on you personal style):

    1. for web interface

    2. for wpf / forms interface

    3. for business and data layers (all of them)

     

    Create a reference folder and deploy all .dlls from the third solution into this folder to be file referenced by the two interface solutions.

    Solution 1 and 2 contain a Appconfig file with all data needed for dependency injection:

     

    1. web interface

    business logic layer: myBusinesslayerClass;myBusinesslayerDLL

    data layer: mySQLDataClass;mySQLDataDLL

     

    2. windows application

    business logic layer: myBusinesslayerClass;myBusinesslayerDLL

    data layer: myVistaDBDataClass;myVistaDBDataDLL

     

    For dependency injection have a look at this article: http://msdn.microsoft.com/en-us/magazine/cc163739.aspx

    Wednesday, March 24, 2010 6:53 AM
  • Yes, I think that'd be the way to go if you gained elsewhere though. 
    Wednesday, March 24, 2010 10:16 AM