Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

build fail
James Mi
#1 Posted : Thursday, May 22, 2014 6:42:58 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/22/2014(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
Hi,

We use some custom build processes. I've added these custom files to Additional files to include configuration. However, I got the error:
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets: The target "NCrunchPrepareForBuild" does not exist in the project.

Now I don't know how to debug this, since I don't know where the missing target is defined and how it is used. Anyone can help?
Remco
#2 Posted : Thursday, May 22, 2014 9:13:10 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi James,

NCrunch automatically adds the 'NCrunchPrepareForBuild' target to the bottom of the project file inside its workspace before it builds the project. If MSBuild is complaining about this being missing, then probably there is something with the syntax of your project file that NCrunch isn't handling correctly.

After your build has failed, try the following:
1. Right click the failed project in the Tests Window
2. Go to Advanced->Browse To Workspace
3. Find the project file in the workspace
4. Open the project file in notepad

.. then examine the file. There should be an 'NCrunchPrepareForBuild' target somewhere near the bottom of the file. Do you notice anything here that seems out of place?
James Mi
#3 Posted : Thursday, May 22, 2014 5:36:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/22/2014(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
Thanks. I checked the proj file under the workspace. Everything looks good to me. I also did 'msbuild' for this proj file within VS prompt and it worked... Any idea on why it failed in NCrunch Tests window?


Below is the the targets got appended in my proj file:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Target Name="NCrunchOutputDataQuery" DependsOnTargets="">
<Message Text="#Expression_93c40b75ebec4db7b1d2f4639170ddac=$(OutDir)$(TargetName)$(TargetExt)" />
<Message Text="#$TargetFrameworkDirectory=;$(TargetFrameworkDirectory)" />
<Message Text="#_SourceItemsToCopyToOutputDirectoryAlways=;@(_SourceItemsToCopyToOutputDirectoryAlways)" />
<Message Text="#_SourceItemsToCopyToOutputDirectory=;@(_SourceItemsToCopyToOutputDirectory)" />
<Message Text="#ReferencePath=;@(ReferencePath)" />
</Target>
<Target Name="_CopyFilesMarkedCopyLocal" DependsOnTargets="">
</Target>
<Target Name="_GenerateAppxPackageRecipe" DependsOnTargets="">
</Target>
<Target Name="NCrunchPrepareForBuild" DependsOnTargets="">
</Target>
Remco
#4 Posted : Thursday, May 22, 2014 10:00:53 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Normally NCrunch will pass the 'NCrunchPrepareForBuild' as a parameter to MSBuild.

If you try doing this using the command line, does it work for you?

msbuild.exe /t:NCrunchPrepareForBuild
James Mi
#5 Posted : Thursday, May 22, 2014 10:20:49 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/22/2014(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
Yes, it worked. As I mentioned, it even works if I use msbuild command line to build the proj. But it still failed inside the NCrunch Test window in VS...
Remco
#6 Posted : Friday, May 23, 2014 12:31:35 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
This is very, very strange. Is there any chance you could submit a bug report right after this build has failed? Maybe there'll be something in the report that can tell us what's happened.

Can you give me any more detail about the nature of your build customisations? Do you notice this problem with any other projects you work with? Perhaps if we can find a project that does work, we can slowly change it to the one that doesn't - thus deducting the exact change that is causing this problem.
James Mi
#7 Posted : Friday, May 23, 2014 1:11:09 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/22/2014(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
I submitted the bug report. Can you see it?

My customization is to import a bunch of properties and targets in the proj, e.g. redirect the $(OutDir), add custom analysis tools targets in <BuildDependsOn>, etc. Unfortunately, no project worked...
Remco
#8 Posted : Friday, May 23, 2014 7:32:09 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks! The report didn't come through unfortunately, I'm not sure what happened there. You're welcome to save it to file and submit it through the contact form if you like.

Something else I thought might be worth looking at is the Project declaration at the top of your project. Normally this should be something like:

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="(- BROKEN LINK -)">

Is there any chance you could copy/paste this for me? NCrunch makes an alteration to this tag in order to reference the missing target, so it's structure is quite important.
James Mi
#9 Posted : Friday, May 23, 2014 10:38:49 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/22/2014(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
I submitted the logs and also the project file. Could you take a look?
Remco
#10 Posted : Friday, May 23, 2014 11:40:58 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks! I've managed to take a deeper look at this. I think we're getting closer to figuring out what's happening here. I apologise as the way in which NCrunch was calling into this target is slightly different to what I had expected.

When NCrunch invokes MSBuild to build the project, it sets a global property called 'PrepareForBuildDependsOn', to: 'GetFrameworkPaths;GetReferenceAssemblypaths;NCrunchPrepareForBuild'

It should be possible to emulate this behaviour by providing the property to MSBuild via the command line. This may help with debugging the issue on your side, for example:

MSBuild.exe /p:PrepareForBuildDependsOn=GetFrameworkPaths;GetReferenceAssemblypaths;NCrunchPrepareForBuild

Unfortunately I can't test this myself as I'm unable to build the project file without its dependencies, but if we can get MSBuild to fail with the generated project on the command line, it should be possible to take NCrunch itself out of the picture, allowing you to analyse things more easily.

My theory is that the nature of your build customisations has introduced a dependency on the sequence of target declarations. If this is true, then moving the empty 'NCrunchPrepareForBuild' target declaration to the top of the project file may allow the project to build.
1 user thanked Remco for this useful post.
James Mi on 5/24/2014(UTC)
James Mi
#11 Posted : Saturday, May 24, 2014 12:47:14 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/22/2014(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
Thanks! This really helps. I can repro by the command line you gave me and got more error information. It turns out we MSBuild another proj in our customization (to pull down all the dependencies). In that proj, the "NCurnchPrepareForBuild" was not appended. So I added that dummy target and the build passed. Looks like NCrunch hides some MSBuild error output. It really makes debugging hard...


"C:\Users\jamem\AppData\Local\NCrunch\8364\33\tfWorkSpace\Authorization.Main\Pr
oduct\Api\Authorization.Rps\Authorization.Rps.csproj" (default target) (1) ->
"C:\Users\jamem\AppData\Local\NCrunch\8364\33\tfWorkSpace\Authorization.Main\CB
T\NuGet\PullToolset.proj" (Build target) (2) ->
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targe
ts(924,7): error MSB4057: The target "NCrunchPrepareForBuild" does not exist in
the project. [C:\Users\jamem\AppData\Local\NCrunch\8364\33\tfWorkSpace\Authori
zation.Main\CBT\NuGet\PullToolset.proj]
Remco
#12 Posted : Saturday, May 24, 2014 1:11:14 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Great stuff. I'm sorry about the lack of debugging information. If you need to see this in future, you can find it by setting your 'Log verbosity' (global config setting) to 'Detailed', then inspecting the output of the build task inside the NCrunch Processing Queue.
1 user thanked Remco for this useful post.
James Mi on 5/24/2014(UTC)
James Mi
#13 Posted : Saturday, May 24, 2014 1:17:11 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/22/2014(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
Got it. Thanks!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.074 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download