SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration

Home Page:https://www.specflow.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto generation of feature.cs fails when using MSBuild that comes with VS2015

johnfettig opened this issue · comments

It appears that there is some problem using MSBuild that comes with VS2015. I would like the feature.cs files to be auto-generated, so I have added

   <Import Project="path\to\nuget-packages\SpecFlow.1.9.0\tools\TechTalk.SpecFlow.targets" />

to my .csproj. This worked fine with the MSBuild that came with VS2013, but now it results in this error:

"nuget-packages\SpecFlow.1.9.0\tools\TechTalk.SpecFlow.targets(47,5): error : Unable to cast object of type 'System.Xml.XmlComment' to type 'System.Xml.XmlElement'."

Googling this error shows that other people are having this problem too: http://forum.ncrunch.net/yaf_postst1608_Build-fails-with-VS-2015-RTM.aspx

👍 we are having this problem as well....

commented

I've got exactly the same problem. If you edit the .csproj file and change the <Project ToolsVersion="14.0" to "12.0", which is the value for the previous version of Visual Studio, specflow runs happily.

It looks like specflow is not able to cope with a ToolsVersion of 14.
This problem won't be seen using the Visual Studio integration because it won't be reading the .csproj file directly.

I don't have this issue when using the generator from v2, so hopefully this will be resolved when v2 is released.

I've been trying to hack around the lack of support for dnx projects (.xproj) by generating a fake .csproj and calling specflow.exe against that on the command line. I was also at the point of getting the " Unable to cast object of type 'System.Xml.XmlComment' to type 'System.Xml.XmlElement'" and @SeaGees suggestion of referencing the previous ToolsVersion/Visual Studio worked for me.

commented

+1

Same problem here, but only when building it with NCrunch. A workaround for his case can be found here:
http://forum.ncrunch.net/yaf_postst1608_Build-fails-with-VS-2015-RTM.aspx

Hmm, looking at this, this actually looks like a real issue that needs to get resolved with SpecFlow. I have not yet run SpecFlow with VS 2015, so perhaps someone with more exp in that can help.

Without any background, I'd first be looking around that "tools version" brought up by @SeaGees .

I was under the impression that the issue was resolved in the v2 branch,
based on an earlier comment.
On 6 Nov 2015 18:28, "Darren Cauthon" notifications@github.com wrote:

Hmm, looking at this, this actually looks like a real issue that needs to
get resolved with SpecFlow. I have not yet run SpecFlow with VS 2015, so
perhaps someone with more exp in that can help.

Without any background, I'd first be looking around that "tools version"
brought up by @SeaGees https://github.com/SeaGees .


Reply to this email directly or view it on GitHub
#471 (comment).

@samholder Oh I see this now, the comment from @johnfettig .

I wonder if we should label this as ready for resolution after v2 is released?

Oh, which reminds me...

I'd be happy to see this fixed in v2, but in the meantime, as I mentioned earlier (and in case anyone else is interested) I hacked together this as a workaround. The main part is this gulpfile.js, which can be then run by the built in Task Runner in VS2015:

image

I haven't, but you could also set the gulp task as a pre-build step in the project.json. The basic action is generate a fake .csproj so that the command linespecflow.exe can run against it. I've gone a couple of steps further to also generate a specflow.exe.config so I can target .NET 4.6, and fix the generated files to work with xUnit 2.

image

You can then see and run your SpecFlow tests from within the VS2015 Test Explorer:

image

@stajs Thank you for going into such good detail on this issue! It's given me a better view into what's going on.

I might be hoping into this on a new instance of VS 2015 in December... but if someone wants to beat me to this, feel free! :)

Apologies all round, I think I've hijacked this thread: the original topic was in regards to MSBuild, where as I'm working around the "SpecFlow for Visual Studio 2015" extension not generating .feature.cs files in .xproj's. They might be related though, I'm not sure.

@darrencauthon Hope you are not waiting on Santa to bring you VS2015 😜

@stajs Well, VS2015 is easy for me now, the free version is functional with SpecFlow now (I think, haven't verified). It's a Windows computer that has been my hurdle. I might have to have one for work soon, so I'll finally be back. Can you believe I've been working on SpecFlow through mono on my Mac for the past few years? 👅

:brain_splode:

In a bid to stop the hijacking of this thread, I've moved my discussion to the Google Group (and also created a NuGet package to generate .feature.cs files in .xproj's).

please, has anyone resolved this. @stajs thanks for the workaround but I'm not able to reference DNX.. also we are looking for solution that doesn't involve adding so much code. any help will be greatly appreciated. thanks!!

@andresd24 try change
Project ToolsVersion="14.0"
to
Project ToolsVersion="12.0"
in the csproj file?

yes

On Tue, Apr 12, 2016 at 12:21 AM, Jackie Weng notifications@github.com
wrote:

@andresd24 https://github.com/andresd24 try change
Project ToolsVersion="14.0"
to
Project ToolsVersion="12.0"
in the csproj file?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#471 (comment)

I'm having the same issue with VS2015 Update 2. Was this resolved?

if you are using 1.9 in 2015 then you need to change
Project ToolsVersion="14.0"
to
Project ToolsVersion="12.0"
in the csproj file.

I thought it had been fixed for 2.0 in VS2015

@samholder But that means that I can't use C#6 features, doesn't it? I.e., no Roslyn.

It would mean that I think yes. But as I said I think it's working for 2.0,
so it's only a work around for 1.9
On 13 May 2016 7:55 p.m., "Saquib Mian" notifications@github.com wrote:

@samholder https://github.com/samholder But that means that I can't use
C#6 features, doesn't it? I.e., no Roslyn.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#471 (comment)

Ah I missed that, my apologies. Thanks!

As it is working for 2.0+, we are closing this issue.
If you have this problem in the actual version, please reopen the issue.

Changing Project ToolsVersion to "12.0". Works well !! Thank you.

commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.