Set application output type programmatically

前端 未结 2 833
逝去的感伤
逝去的感伤 2020-12-21 08:40

I am programming an application using the command line application output type to display debug information in the console while MOGRE is handling the actual window creation

2条回答
  •  余生分开走
    2020-12-21 08:59

    You can achieve this if you edit the .csproj manually:

    • Right click on the project node in Solution Explorer
    • Select "Unload Project"
    • Right click on the project node in Solution Explorer
    • Select "Edit MyApp.csproj"

    Move the property group Xml element from the Xml element without Condition to the property group with conditions corresponding to build configuration / platform.

    Before:

    
      
        ...
        Exe
        ...
      
      
        ...
      
      
        ...
      
    

    After:

    
      
        ...
      
      
        ...
        Exe
        ...
      
      
        ...
        WinExe
        ...
      
    

    And finish:

    • Right click on the project node in Solution Explorer
    • Select "Reload Project"

    Here is a proof example:

    class Program
    {
        public static void Main(string[] args)
        {
    #if DEBUG
            Console.WriteLine("test");
    #else
            Application.Run(new Form1());
    #endif
        }
    }
    

    It works, but I don't think this is officially supported, so use at your own risk :-)

提交回复
热议问题