Build/Test Issues

Project failing to build - where to find the errors?

Started by m.e. on 11,462 views

I've just tried to add NCrunch to an existing solution. The solution msbuild projects are somewhat customized, so I did not expect it to work right away. As expected, NCrunch reports that projects are 'failing to build'

But I don't see any actual build error message text anywhere - just notification about the error, but not details - the Output/Build and Output/'NCrunch Output' windows are empty.

Is there any other place to see the build error messages? It is kind of hard to troubleshoot them blindly.
Most build errors should be shown in the Tests Window. As you have a customised build, it's possible that the build is failing due to an NCrunch internal problem of some kind - in which case you should have a look in the processing queue instead, which gives a much more physical output from the build process. It's often worth setting the logging to a more detailed verbosity in your NCrunch global configuration, as this will allow the failed task in the processing queue to show more information. It would be great if you can share the error message here so I can help with understanding it and further improving the error reporting with future versions.
Tanks - the processing queue is useful, missed it before.

Here is the exception:

[17:45:30.1262-BuildTask-11] ERROR (Internal): System.InvalidOperationException: Cannot modify an evaluated object originating in an imported file "...\Microsoft.Common.Before.targets".

Server stack trace:
at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args)
at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowInvalidOperation(Boolean condition, String resourceName, Object arg0)
at Microsoft.Build.Evaluation.Project.VerifyThrowInvalidOperationNotImported(ProjectRootElement otherXml)
at Microsoft.Build.Evaluation.Project.RemoveItemHelper(ProjectItem item)
at Microsoft.Build.Evaluation.Project.RemoveItem(ProjectItem item)
at nCrunch.VSIntegration2010.MSBuildIntegration.BuildableProject.RemoveItems(String itemName)
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

It seems to be related to a line in the .csproj
<Import Project="$(EnvironmentConfig)" />
where EnvironmentConfig is environment variable that points to shared config - all our projects start with this line.
If I avoid this line in NCrunch build, the build proceeds further (but fails with another error - now reported in Tests Window).

Edited

This makes good sense. Usually where I've seen this problem it relates to included build files that specify their own <ProjectReference> or <AssemblyReference> tags. NCrunch needs to manipulate/remove these tags in order to control the assembly references used during the build process.

I have an item in my backlog to improve the error reporting around this so that people can better understand why these sorts of things happen. Unfortunately because the error is caused by what can be quite a complex piece of build customisation, I've yet to find a clean way to actually solve the problem within NCrunch. My recommendation is to remove any <ProjectReference> or <AssemblyReference> declarations from the included build file and instead move these to your own project file. If you're uncomfortable with making this change for non-NCrunch builds, you can use the NCrunch build environment variable $(NCrunch) == '1' to implement conditional logic inside your build process.


Cheers,

Remco

Edited

Post a reply

Log in to reply.