Steve
Steve

Reputation: 185

VS2013 C++ Custom Build Tool not working

My apologies for the lengthy text, but I've been having some trouble using the Custom Build Tool feature in VS2013 for C++ projects. I want to take a project's "resource.h" file and generate an output file which, for these purposes, we'll call "resource.out".

I wrote a tool that takes two command-line parameters - the "resource.h" file, and the "resource.out" file. I first tried this on a simple app-wizard-generated doc/view application MFCApplication1. I added file "resource.x" as a dummy file to get "compiled" using the custom build tool. On that specific file, I set the "Item Type" to "Custom Build Tool", and when configuring the tool I have the following:

Command Line: "<path-to-tool>" resource.h .\res\resource.out
Outputs: .\res\resource.out
Additional Dependencies: resource.h

This works. When I build MFCApplication1, I see the following in my output window:

1>  Performing Custom Build Tools
1>  Successfully generated resource out file ('res\resource.out') 

The second line is output from my custom build tool. So in this simple test, everything works as I'd expect.

Now I'm trying the same thing on my real code. I have a solution with a number of projects, and one project is reponsible for taking another project's resources and generating a dll. The directory structure looks like:

Main
    MainApp
        resource.h
    MainRes
        MainRes.vcxproj references "..\MainApp\resource.h"

So the MainRes project references the resource file from the MainApp project. Following what was successful in my MFCApplication1 experiment, I added "resource.x" to the main app, and reference it in MainRes:

Main
    MainApp
        resource.h
        resource.x
    MainRes
        MainRes.vcxproj references "..\MainApp\resource.h"
        MainRes.vcxproj references "..\MainApp\resource.x"

In the MainRes project, I selected "resource.x" and via the context properties, set its "Item Type" to "Custom Build Tool", and configured it as:

Command Line: "<path-to-tool>" ..\MainApp\resource.h ..\MainApp\res\resource.out
Outputs: ..\MainApp\res\resource.out
Additional Dependencies: ..\MainApp\resource.h

Now when I attempt to compile "resource.x" in MainRes, I get the following warning (warning MSB8018: No outputs specified for item "..\MainApp\resource.x"):

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(170,5): warning MSB8018: No outputs specified for item "..\MainApp\resource.x". Its custom build command will be skipped.

So I thought maybe it's a context thing and changed the configuration to:

Command Line: "<path-to-tool>" resource.h .\res\resource.out
Outputs: .\res\resource.out
Additional Dependencies: resource.h

I get the same warning. I don't understand what I'm doing wrong here. I have the 'Outputs' set to a file, and I have the output file in the command line. Thanks in advance for anyone's help on this one. I've spent way too much time on it already...

Upvotes: 2

Views: 988

Answers (1)

Steve
Steve

Reputation: 185

Soooo... I finally figured out that for some reason, modifying the Custom Build Tool configuration using the editor was actually saving the data into the vcxproj under the wrong Configuration. Even though I had the Configuration and Platform set correctly in the editor, it was writing to a different configuration in the file. Who the hell knows why that is, but lesson learned - always check your vcxproj file!

Upvotes: 1

Related Questions