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

Notification

Icon
Error

Build fails with VS 2015 RTM
ncrunchuser1
#1 Posted : Tuesday, July 21, 2015 12:30:08 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/21/2015(UTC)
Posts: 13

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
Project builds fail with the following message "..\packages\SpecFlow.1.9.0\tools\TechTalk.SpecFlow.targets (47, 5): Unable to cast object of type 'System.Xml.XmlComment' to type 'System.Xml.XmlElement'.".

The same project worked fine with VS 2015 RC but broke after upgrading to VS 2015 RTM. The tests are created with SpecFlow. The project builds fine in VS with no warnings and the SpecFlow runner and VS are both able to run the tests. Tried with version 1.9.0 and 1.8.1 with the same issue.
Remco
#2 Posted : Tuesday, July 21, 2015 10:11:01 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)
Hi,

Thanks for sharing this issue.

The problem appears to be a compatibility issue between SpecFlow and VS2015.

When NCrunch loads your project, it detects the reference to the SpecFlow binary and automatically includes the SpecFlow.targets file inside your project as an import. The reason for this is to allow NCrunch to be able to regenerate SpecFlow tests every time it builds your project, which is something that won't happen without this targets file included.

So it's the SpecFlow test/step generation that is causing the build to fail. I'm not sure how heavily you're using SpecFlow, but I expect that this issue may be a major one for you regardless of whether or not you use NCrunch. I recommend reporting it to them.

If you'd like to make your NCrunch build work in the same way as the Visual Studio build (and by-pass the error), open up the TechTalk.SpecFlow.targets file inside your Nuget packages directory, find the 'GenerateAll' task invocation on line 47, and comment it out. For example:

<Target Name="UpdateFeatureFilesInProject" DependsOnTargets="BeforeUpdateFeatureFilesInProject">
<!-- GenerateAll
ShowTrace="$(ShowTrace)"

BuildServerMode="$(BuildServerMode)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"

ProjectPath="$(MSBuildProjectFullPath)"
ForceGeneration="$(ForceGeneration)"
VerboseOutput="$(VerboseOutput)">
<Output TaskParameter="GeneratedFiles" ItemName="SpecFlowGeneratedFiles" />
</GenerateAll -->
</Target>
2 users thanked Remco for this useful post.
ncrunchuser1 on 7/21/2015(UTC), qujck on 9/2/2015(UTC)
Graham
#3 Posted : Wednesday, July 29, 2015 11:40:33 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/24/2014(UTC)
Posts: 3
Location: United Kingdom

Was thanked: 2 time(s) in 2 post(s)
Probably obvious, but you can also just change the target to have a condition by changing its first line like this and leaving the rest the same
<Target Name="UpdateFeatureFilesInProject" DependsOnTargets="BeforeUpdateFeatureFilesInProject" Condition="'$(NCrunch)' != '1'">
1 user thanked Graham for this useful post.
ncrunchuser1 on 7/29/2015(UTC)
ncrunchuser1
#4 Posted : Wednesday, July 29, 2015 3:37:50 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/21/2015(UTC)
Posts: 13

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
Thanks Graham!

I didn't know about that NCrunch parameter (guess I need to take a look at the NCrunch .targets file). That will come in handy in the future for sure!
ncrunchuser1
#5 Posted : Wednesday, July 29, 2015 6:30:02 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/21/2015(UTC)
Posts: 13

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
I see there's no .targets file but I found the info about it and other environment variables in the online help. Guess I should read the manual more often :)

Thanks again!
ncrunchuser1
#6 Posted : Tuesday, August 4, 2015 6:43:52 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/21/2015(UTC)
Posts: 13

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
Update on this:.

I did change to use the $(NCrunch) variable as Graham suggested. A couple of behaviors to be aware of if you use this:


  • You need to save the .feature file in order for NCrunch to pick up the latest changes
  • If you add the generated test file as a link, NCrunch will not detect changes in the .feature file - even after saving and the generated file is updated. The workaround is to modify a different file under test or right-click the test in NCrunch and choose "Reload and rebuild selected component"


Other than that, everything else seems to be working fine.
1 user thanked ncrunchuser1 for this useful post.
Remco on 8/4/2015(UTC)
Ruskin
#7 Posted : Tuesday, December 29, 2015 7:57:46 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/29/2015(UTC)
Posts: 3
Location: New Zealand

Thanks: 1 times
Changing the targets file is all well and good if you checkin/commit the targets file. This is not a solution if you are using nuget to download the package at compile time and therefore getting a new file on each compile. Also we don't commit these files to the repository so changing it would be a bit counter productive. Is there any other way around this to get Ncrunch working?
Remco
#8 Posted : Tuesday, December 29, 2015 8:17:45 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 Ruskin,

Another option could be to try adding the Condition="'$(NCrunch)' != '1'" to the <Import> tag in the project that is referencing the SpecFlow targets file. This will prevent the project from referencing the specflow build targets entirely.

Have you tried contacting SpecFlow about this problem? It's a bit of a concern if you're still encountering this issue so long after VS2015 hit RTM. I would think that a more solid solution would be available for this from their side by now.
Ruskin
#9 Posted : Tuesday, December 29, 2015 8:05:48 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/29/2015(UTC)
Posts: 3
Location: New Zealand

Thanks: 1 times
Hi Remco,
Hmm the project file which uses the Specflow targets does not explicitly import the targets file.

I don't believe the problem is within VS2015 as the issue is only exposed while building via NCrunch.

There are few items which VS2015 simply builds out of box but when built via NCrunch, it fails, this being one of them. Most of the issues can be resolved by changing the NCrunch configuration settings, e.g. using "copy files to workspace" setting. Although it would be nice to get NCrunch build working a bit better with Nuget given than everything now is released using Nuget.

Any other suggestions?

Regards,
Ruskin
Remco
#10 Posted : Tuesday, December 29, 2015 9:52:26 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)
Hi Ruskin,

Sorry, I've just rechecked how this is put together. NCrunch is deliberately adding the targets reference behind the scenes so that it can re-generate the SpecFlow features automatically on each build. It's the SpecFlow feature re-generation step that's causing the build to fail, as this particular build task doesn't work inside the MSBuild 14.0 environment. I assume you are re-generating your SpecFlow features manually using the IDE integration.

I've noticed that SpecFlow have resolved this problem in their latest pre-release version. The actual release version of SpecFlow in Nuget hasn't been updated since 2012, so it's easy to understand why it isn't working properly.

I recommend trying the pre-release version of SpecFlow to see if this will work for you. Disabling or removing NCrunch's integration with SpecFlow's feature re-generation is actually very painful as this breaks the continuous flow you get when editing tests.
1 user thanked Remco for this useful post.
Ruskin on 12/29/2015(UTC)
Ruskin
#11 Posted : Tuesday, December 29, 2015 10:11:13 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/29/2015(UTC)
Posts: 3
Location: New Zealand

Thanks: 1 times
Thank you for that. A bit painful using pre-release packages but should suffice for now :).
Remco
#12 Posted : Tuesday, December 29, 2015 10:13:11 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)
Ruskin;8178 wrote:
Thank you for that. A bit painful using pre-release packages but should suffice for now :).


Hopefully they release it soon :)
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.076 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download