Thanks Remco!
You pointed me in the right direction and I figured it out after some digging. There were two issues.
1. Using the incorrect relative path to import the .targets fileThe .targets file is located in the solution folder. I had the import as:
Quote:<Import Project="$(MSBuildThisFileDirectory)..\CodeContracts.targets" />
I noticed in the NCrunch temporary folder that this file was not copied over. Changing to the following fixed the issue:
Quote:<Import Project="..\CodeContracts.targets" />
Now the file gets copied to the NCrunch temporary folder in the correct relative location.
2. NCrunch does not see Configuration Manager settings.The defines are different based on if building in Debug or Release mode. In the Configuration Manager, I specified the appropriate configuration for the project regardless of the active solution configuration. This works for mstest and SpecFlow but apparently, NCrunch does not see this configuration.
Fix: Changed the NCrunch configuration setting
"Use build configuration" for the projects to
Debug or
Release as appropriate (only seems to be a problem with Release but I explicitly set Debug as well, just in case).
Quick followup question:Is it possible to have NCrunch run the test using all the configurations? If not, this would be a great feature to have :)
Right now, I'm creating a separate project per configuration that I need - which is quite a few. It would be much nicer to have one project and several configurations.