openshac;7071 wrote:I tried specifying the condition you mentioned however it didn't change the behaviour. And it would also mean the additional include directories would get omitted if $(NCrunch) == '1', but I guess that modification was just to test things.
Yes. Sorry ... it's likely this wouldn't have actually worked, even if it worked ... if that makes any sense :/
We're running out of options here. The big issue is that there isn't a way for NCrunch to separate the included files from other source files in your solution - MSBuild is simply combining them and returning a unified result set. This means that either the files get copied, or they can't be referenced at all and the build will completely fail.
I think the best option may to be look at ways in which we can exclude this particular project/assembly from NCrunch itself, and use NCrunch for the rest of your solution. Since NCrunch won't support code coverage over a C++ project anyway, there is probably little value in having it as part of the NCrunch build tree.
The way to do this is by building the output assembly from the project, then referencing the built assembly directly (from all depending projects) instead of the C++ project. This will likely make a mess of your build sequence, so the best way to handle this would be to make the references conditional on NCrunch being resident so that the <AssemblyReference> is used for NCrunch, and the <ProjectReference> is used for Visual Studio. This will let you use NCrunch without making a mess of your VS build. The only way you can do this is by modifying the project files manually and adjusting the references.
So the following:
<ItemGroup>
<ProjectReference Include="..\MyCppProject\MyCppProject.vcxproj">
...
</ProjectReference>
</ItemGroup>
Would become:
<ItemGroup>
<ProjectReference Include="..\MyCppProject\MyCppProject.vcxproj" Condition="$(NCrunch) != '1'">
...
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="..\MyCppProject\Bin\Debug\MyCppProject.dll" Condition="$(NCrunch) == '1' />
</ItemGroup>
When this change has been made, you'll need to do a rebuild of the C++ project in VS every time you make changes to it. This is because NCrunch will be hooked up to the output of this project, so it won't detect the change until you rebuild manually.
You'll need to turn on the 'Ignore this project completely' NCrunch project-level configuration setting for the C++ project, otherwise it'll still try to build it and consume valuable resources.
NCrunch may give you a warning about a 'lost reference' - just ignore this.