Create multiple versions of a project in Visual Studio using Build Configurations

后端 未结 2 977
北恋
北恋 2020-12-18 05:47

I neeed to create multiple versions of my project using configuration just like we do with #define, #if, #endif.

The down side

相关标签:
2条回答
  • 2020-12-18 05:54

    In addition to Michael Freidgeim´s solution you can use attribute conditional for central initalisation operations or other void functions:

    [Conditional("DEVELOPMENT")]
    public static void InitDemo()
    {
          Models.LogFile.ErrorLog("This is a Development Version!");
          // init settings
    }
    

    Found here: http://msdn.microsoft.com/de-de/library/4xssyw96%28v=vs.80%29.aspx

    0 讨论(0)
  • 2020-12-18 05:59

    Configuration Manager exist for this reason.

    • Go to the Configuration Manager and create a New Configuration copying from the predefined DEBUG configuration
    • Name the configuration DEVELOPMENT and apply to all projects
    • Select as Active Configuration the DEVELOPMENT configuration (should already be the active one)
    • Go to the properties page of each project requiring #if DEVELOPMENT conditional compile and insert the DEVELOPMENT symbol in first textbox of the BUILD tab

    Now each of your projects can use the #if DEVELOPMENT preprocessor directive

    If you need this also for RELEASE repeat the above steps but copy from predefined RELEASE configuration and give a different NAME

    Now switching from a configuration with or without the DEVELOPMENT symbol defined could be done directly from the Solution Configurations combo Tool present in the Standard Toolbar of Visual Studio without editing each project.

    You can also view MSDN article How to: Create and Edit Configurations

    0 讨论(0)
提交回复
热议问题