Is it possible to pass a compilation parameter for a specific project in a solution, but at the same time, only the solution is specified for compilation?

It is necessary that the program be built in debug mode as a console application, and in release, as Win32. Or will it help only consistent build projects?

    1 answer 1

    Well, in principle, this can be done, although for Visual Studio this is not a fully supported script.

    From the point of view of compilation, .csproj is a full-fledged script for MsBuild, and in it you can set any conditions. For example, if you create a WPF application, open .csproj for editing, replace the line

    <OutputType>WinExe</OutputType> 

    on

     <OutputType Condition=" '$(Configuration)' == 'Debug' ">Exe</OutputType> <OutputType Condition=" '$(Configuration)' != 'Debug' ">WinExe</OutputType> 

    This executable file will be created as you need.


    Disadvantages: since this is not a supported scenario for Visual Studio, in my test application the output to the console did not occur if you run the program through F5 (Start Debugging). If you run via Ctrl-F5 (Start Without Debugging), everything works as it should.

    • Let almost a crutch, but that's enough for me, I collect through the console. - LLENN
    • @Yami: If you collect via the console, there should be no problems. - VladD