visual-studio-2010qtcustom-build-step

Why does adding custom build step in Visual Studio Qt project with Qt add-in stop automatic MOC and UIC steps?


I have a Visual Studio Qt project using the Visual Studio Qt Add-in. The Add-in automatically creates a Custom Build Tool rule for .ui files and for each header file that has classes with the Q_OBJECT declaration to run the UIC and MOC respectively.

This all works perfectly until I add a Custom Build Tool rule for the project as a whole. In this instance, the rule is specific to the Release build and invokes code signing and is set to Execute after: Build. With this configuration, the Debug build works correctly, but the Release does not automatically execute the MOC or UIC. I can right click the Q_OBJECT headers and .ui files in the project browser and manually force a Compile for all necessary files, and they are correctly MOC'd and UIC'd and can then build, but a rebuild or build after clean always fails.

Why has adding a project Custom build rule for the project appear to have suppressed the Custom Build Tool rules associated .ui and Q_OBJECT headers?


Solution

  • In your custom build step, set "execute after" to BuildGenerateSources.

    This is represented in the vcxproj-file by adding the line

    <CustomBuildAfterTargets Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">BuildGenerateSources</CustomBuildAfterTargets>
    

    to the <PropertyGroup> block