5

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?

Clifford
  • 88,407
  • 13
  • 85
  • 165

1 Answers1

4

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

Cerno
  • 751
  • 4
  • 14
  • Thanks - although the moment has passed! In the end I solved the problem laterally by making it a *pre-build step* in the installer project to which the application is a build dependency. – Clifford Aug 05 '15 at 12:42
  • Yeah, I thought about doing the same thing by extending the prebuild step I already had in place, but luckily there is a way to solve this properly. – Cerno Aug 05 '15 at 12:59