Visual Studio 2008 Managed Incremental Build doesn't work
I have "Managed Incremental Build" turned on in my managed C++ project. I have a DLL written in C#, and the solution contains both the C++ and C# projects. I have not defined any dependencies between the projects, but the C# DLL is referenced by the C++ project.
The problem is that whenever the C# project is rebuilt, the C++ projects does a full rebuild. I'm getting this error message when this happens:
Cannot inspect c:\MyProj\MyCScode.dll. Assuming significant changes.
I'm running Windows 7 in a VM (could this be a timing problem?).
After some research, a colleauge of mine tells me that this is a confirmed bug in Visual Studio 2008 SP1, that there's no hotfix available, and that removing SP1 solves the problem. I don't have any link to back that information, though.
Our solution was to move the C# implementation files from the C++ project, and have them compile using a custom build step (using the /target:module parameter to csc.exe), and to include the object files in the C++ source files that referenced our managed C# types, like this:
The netmodule must use the .obj extension, this seems to be a bug in the way Visual Studio determines what inputs will be used for the linker (normally you'd call it .netmodule instead).
We still get a full rebuild of all C++ source files that have the #using, whenever the C# files are updated. But this is better than a full rebuild of the entire project.
I think I have found a workaround:
I explicitly added $(OutDir) to “Resolve #using References” in the “C/C++ | General“ option page of each C++/CLI project. After this the "Cannot inspect ... Assuming significant changes." message didn't appear anymore in case of assembly internal changes and the managed incremental build worked as expected.