Вопрос

I need to make sure a custom build tool that operates on a lot of files is always run when one of those files are changed.

I know you can specify "Additional Dependencies" for the custom build tool, but is there a better way than specifying one file per line?

Это было полезно?

Решение

"Additional Dependencies" is the correct and only documented way. You could adjust the contents of this field for the build tool in the Project file using an external tool to save on the troubles of doing a copy & paste & typo-adjust.

Другие советы

Just made the build tool depend on one file. Created another custom build tool that runs before it and that touches this file if any of the real dependencies have changed. The advantage is that I now have quite a lot of flexibility and don't need to change any of the project settings if the dependencies change - that's taken care of via a database that the new custom build tool accesses.

It won't be quite as reliable, but you could put all files in a subfolder and just make the folder a dependency.

A little bit hack:

(1) group the dependency files into a separate folder

(2) create a jscript file detect.js as follow:

var output = WScript.arguments(0);
var folder = WScript.arguments(1);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var objOutput = fso.GetFile(output);
var objFolder = fso.GetFolder(folder);
// if the output file is older than input folder,
// delete output file to force regenerate
if (objOutput.DateLastModified < objFolder.DateLastModified) {
    fso.DeleteFile(objOutput);
} else {
    // if the output file is older than one of files in the input folder,
    // delete output file to force regenerate
    var e = new Enumerator(objFolder.Files);
    for (; !e.atEnd(); e.moveNext()) {
        if (objOutput.DateLastModified < e.item().DateLastModified)
            fso.DeleteFile(objOutput);
            break;
        }
    }
}

(2) Add command lines to Pre-Build Event as follow:

cscript.exe /nologo detect.js $(Output) $(InputFolder)

(3) Setup the Custom Buld Step to force the Pre-Build Event to occur, i.e.

Command Line: echo --------------
Outputs: echo.fake
Execute After: PreBuildEvent
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top