I've written a C# preprocessor that I've incorporated into my .csproj projects by invoking it using the BeforeBuild MSBuild target. This works OK except that when the preprocessor has modified one or more of the C# source files in the project (happens fairly seldom) the C# compile step uses a cached version of the source file. After the build is complete Visual Studio prompts me with a message "filename-this-or-that This file has been modified outside of the source editor. Do you want to reload it?". So then I have to reply Yes and rebuild the project to get it to use the modified source files.
Is there some way to get Visual Studio to detect that the source files have been modified and use the updated versions in its compile step? Or should I be invoking my preprocessor in some other way rather than using the BeforeBuild target?