How do I use Configuration Manager to produce 2 slightly different versions of same program?

Posted on 2004-10-23
Last Modified: 2013-12-03
I am pretty sure the configuration manager in visual studio is the place to figure this out, but don't know how.  I need to create 2 projects that have most of the same forms and code, but where the entry form on one deployment will be tailored for a specific client login procedure and another deployment that has a more generic login procedure.  
Question by:thefumbler
    LVL 14

    Accepted Solution

    You could use conditional compilation arguments to do this.  Open your project. Next select Project --> Properties.

    In the BUILD section under Configuration, you can add your own constants as:


    Next in your code you can include or leave out sections of code using the conditional compilation statements as:

    #if CUSTOM_CLIENT Then
        Code for custom client stuff goes here

       Code for everyone else goes here

    #End If

    You can set up your own build configurations to include this symbol or not...

    Note that if the symbol is not defined, it will evaluate as false.

    LVL 1

    Author Comment


    I expected a simpler way to do this without code - is this really the only way?   It just seems like this would be a very common issue for many developers and that there should be a option to select which files are included in which build.  I would prefer not to change the code in the generic version for everyone because I would have to deploy a new version for no benefit to those users.  This type of option would also be helpful in developing and testing so I can have very client specific files in a build for release and files related to my test development system in another build.  

    I am still getting feet wet in .net so I may be out to lunch, feel free to say so.
    LVL 14

    Expert Comment

    The project structure in Visual Studio .Net is file-based. That is, when you create a new project, files are created under the folder hierarchy for the project.  This even happens when you add an "existing" item to a project. In this case, Visual Studio doesn't point to existing file location, it goes over there and COPIES it to your local project folder. This makes it impossible to share source code between projects.

    It sounds like you want to exclude/include various files for a project build. Since the build system in VS is _Project_ based and not file based I think you are out of luck.

    An alternative to the conditional compilation idea I posted above would be to maintain 2 separate projects. But that is more headache than it's worth, in my opinion.

    I may be out to lunch on this one as well, but as far as I know, the solutions I presented are the only ways to deal with this.
    LVL 1

    Author Comment

    I haven't been able to find any better way, so ptakja's method is probably the best.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    The Complete Ruby on Rails Developer Course

    Ruby on Rails is one of the most popular web development frameworks, and a useful tool used by both startups and more established companies to build strong graphic user interfaces, and responsive websites and apps.

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now