Thanks for your responses guys, and just to say that I have managed to adapt PIEBALDconsult's creative solution into something that will work in a straight-through build run with MSBuild rather than Csc. I can now run VS Projects and have MSBuild selectively pre-process files that have #includes in them, and process the others normally in one run. The 'trick', if you like, was to set up a custom Task that does the preprocessing if it finds a file with a given extension (and I've used PIEBALD's .csi). All the code is actually written in .cs files, but the build is looking for .csi's in specified cases, and the custom Task is doing the pre-processing and generating these 'pre-build'. All I have to do is link my Task into the project in the 'BeforeBuild' targets:
<Project ... >
...
<Target Name="BeforeBuild">
<PreProcessor
Sender="$(RootNamespace).$(AssemblyName)"
Sources="@(Compile)"
/>
</Target>
<UsingTask Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
TaskName="PreProcessor"
AssemblyFile="bin\Debug\Com.Cinsault.PreProcessor.dll"
/>
<UsingTask Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
TaskName="PreProcessor"
AssemblyFile="bin\Release\Com.Cinsault.PreProcessor.dll"
/>
</Target>
</Project>
and the pre-processing of the headers is done before the build starts. I suppose there are just a couple of issues though. The most inconvenient is that, as the coding is done in the .cs file, but the build is working off the intermediate file, then any errors or warnings in VS are pointing to the wrong one, and the line numbers will be out too because of the included header code. The other is that, on the first run, MSBuild must find something for the files that it expects, even if these are empty, otherwise - even though the pre-build Task gets to do it's stuff first - MSBuild is looking ahead and saying "I got nothing to work with here!" Could be useful though, so thanks again. BS