Our team supports the automation efforts of users who are on the latest version of Specflow, as well as those who are not. So the need exists to bounce between the current .vsix for Specflow on VS2017, as well as the .vsix that expects Specflow 2.1 (right now I'm stuck because any feature.cs regeneration fails with a can't find 2.2). I did attempt pulling from https://github.com/techtalk/SpecFlow.VisualStudio/tree/release/v2017.1, but am getting several unresolved references to Microsoft.VisualStudio.
Any way to simply pull the .vsix that works with SpecFlow 2.1?
Edit: Thanks Andreas, the fast response is much appreciated. I will go ahead and open an issue on GitHub if you wish, but I didn't mean to imply that there is an issue with the extension. It may well be a misunderstanding on my part - I though that the current Specflow VS Extension 'expects' SpecFlow 2.2.
As you know, SpecFlow 2.2 uses NUnit 3.x, whereas SpecFlow 2.1 uses NUnit 2.x, which is essentially a breaking change for solutions that used obsoleted features of NUnit 2.x.
So when I switch from a branch that used SpecFlow 2.2 to another branch that uses 2.1 (even tried clearing AppData/Local/Temp), the SpecFlowGenerator will fail because it's looking for SpecFlow 2.2, which we don't want to use in the pre-conversion branch because of the NUnit issue.
I'd love to not have to swap out the extension, as long as I can continue to switch branches between one that uses SpecFlow 2.1 and one that uses 2.2. The app.config for the project does contain a binding redirect -
<dependentAssembly>
<assemblyIdentity name="TechTalk.SpecFlow" publicKeyToken="0778194805d6db41" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.1.0" newVersion="2.1.0.0" />
</dependentAssembly>
So the question is how to use the up-to-date extension even when bouncing between branches that use 2.1 and 2.2. Thanks again!
The Visual Studio extension supports all versions of SpecFlow from 1.9 up to 2.2.
If you have problems with it, please open an issue on GitHub, so that we can find the reason together.
Update:
SpecFlow has no direct reference to NUnit. Not with 2.2 or anything before. There is a NuGet package SpecFlow.NUnit which has a package dependency to NUnit, but this package helps only configuring SpecFlow for NUnit. But you don't need this, when you are doing the configuration manually (setting the unit test provider to NUnit in the app.config).
It could be, that when you are switching branches and don't restart Visual Studio between, that we have still a reference to the previous SpecFlow assemblies and so a Version hickup is created.
Full disclosure: I am one of the maintainer of SpecFlow.
In case anyone else wrestles with this, here's the fix that worked for me with this particular sequence of events
1) you have a branch that uses SpecFlow 2.1
2) you upgrade to the latest VS SpecFlowExtension
3) you switch to another branch that uses SpecFlow 2.2 and successfully have the feature.cs generated
4) you get a request from a user needing support on 2.1, switch to that branch, make a change to a feature file, and get slammed with SpecFlow 2.2 not found
5) even after closing all instances of VS, deleting LocalAppData/Temp/VisualStudioTestExplorerExtensions, starting VS and opening the solution that uses the SpecFlow 2.1 drivers, then attempting to save still results in SpecFlow 2.2 not found, even with a binding redirect to 2.1
Apparently something is cached to disk (reboots didn't help) that isn't immediately apparent. The solution was to have separate clones - one for the branch that referenced SpecFlow 2.1 and an entirely separate clone for the branch that referenced SpecFlow 2.2.
Now I no longer get SpecFlow Generator errors - the trick is not to use separate branches, but separate clones.
Related
On a project I am working on, I am maintaining some Feature Tests written in SpecFlow. Our team started using Visual Studio 2017 about a year ago, and we finally got around to doing some upkeep on our tests!
Our tests for the project I'm working on were originally written in SpecFlow 2.3.2, and were last updated in Visual Studio 2015.
The SpecFlowSingleFileGenerator is known to not work on VS 2017, so I spent the better part of yesterday changing our suite to use the MSBuildSingleFileGenerator instead as detailed in this article in SpecFlow's official documentation
Problem:
Locally, I can build my solution, including the Feature Test project just fine.
However, I keep getting the following error when I try to build the project on our build server:
[exec] C:\CheckoutDirectory\My Awesome Project\packages\SpecFlow.Tools.MsBuild.Generation.2.3.2\build\SpecFlow.Tools.MsBuild.Generation.targets(45,5):
error MSB4036: The "GenerateAll" task was not found.
Check the following:
1.) The name of the task in the project file is the same as the name of the task class.
2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface.
3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" directory. [C:\CheckoutDirectory\My Awesome Project\AwesomeProject.FeatureTest\AwesomeProject.FeatureTest.csproj]
I should point out that our team has no experience with writing MS Build tasks, as hitherto we haven't needed to; we use NAnt build scripts on TeamCity to manage our build work. It's clear that error message would be helpful...if we knew literally anything about it.
Now, normally the correct answer would be: Google it. I did that, and this specific error has no pertinent results.
Additionally, this is blocking my team, since we need our build to work. I don't have the time to do the research and education necessary to properly understand how MS Build technology works. That wil have to come later.
Question:
Bearing in mind that SpecFlow has broken our process, and our team's lack of knowledge about the MS Build system: I need to know how to get around the "GenerateAll" task was not found error. What do I do to get around it?
Secondary Question:
I'm also open to lateral thinking. Is there some way to hack either VS 2017 or SpecFlow to make the SpecFlowSingleFileGenerator "compatible" with each other? The objective here is NOT to avoid making changes, but to control the changes. I need a path towards transitioning from the old file generator to the MS build generation system.
Additional Information:
So, I did some digging, and I found a place where "GenerateAll" is being called in the SpecFlow.Tools.MsBuild.Generation.targets file:
<Target Name="UpdateFeatureFilesInProject"
DependsOnTargets="BeforeUpdateFeatureFilesInProject"
Inputs="#(SpecFlowFeatureFiles)" Outputs="#(SpecFlowFeatureFiles->'%(RelativeDir)\%(Filename).feature.cs')">
<GenerateAll
ShowTrace="$(ShowTrace)"
BuildServerMode="$(BuildServerMode)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
ProjectPath="$(MSBuildProjectFullPath)"
ForceGeneration="$(ForceGeneration)"
VerboseOutput="$(VerboseOutput)"
DebugTask="$(SpecFlow_DebugMSBuildTask)"
>
<Output TaskParameter="GeneratedFiles" ItemName="SpecFlowGeneratedFiles" />
</GenerateAll>
</Target>
Because I've confirmed that this is being copied out to the build server, the situation is yet more mysterious. It appears that the NuGet package is being pulled down faithfully. Therefore, I can't figure out why my local copy is behaving differently than the copy on the build server.
I am not sure where you found this statement:
The SpecFlowSingleFileGenerator is known to not work on VS 2017
The SpecFlowSingleFileGenerator is working in VS2015, VS2017 and VS2019. We see it as a legacy feature, but it's still there. Since some weeks it is disabled by default, but you can enable it in the options.
It works for SpecFlow >= 2.3.2 and 2.4. For SpecFlow 3 you have to use the MSBuild integration. There are some problems with older versions of SpecFlow, but with them it can also work. It depends on your setup.
About your MSBuild error:
The MSBuild Task for SpecFlow < 3.0 is in the specflow.exe. Is it on your build server?
It is part of the SpecFlow NuGet packages. Normally you get this kind of error if MSBuild can't find the assembly where the task is.
For "debugging" problems with MSBuild, I can highly recommend to use the MSBuild Structured Log Viewer (http://msbuildlog.com/). With it, it makes it easy so see what is happening in your build.
We have an example for MSBuild Code- Behind- Generation with SpecFlow 2.3.2 here: https://github.com/techtalk/SpecFlow-Examples/tree/master/MSBuild/OldCSProj_SpecFlow232
You could compare your project with this example.
Full disclosure: I am one of the maintainers of SpecFlow.
I upgraded to Visual Studio 2017 last week. A solution with several test projects using MSTest v1 seemed to be fine at first. Most test projects execute tests fine. This is .NET Framework, not .NET Core.
However, there is one project where I am encountering issues. It's an integration test project, meaning it runs web application tests using the ChromeDriver and Selenium. This project references NUnit, though that reference comes from another project reference. I am not actually using NUnit as my test framework.
This is the error when trying to run any test in that particular test project:
Could not find test executor with URI 'executor://mstestadapter/v1'. Make sure that the test executor is installed and supports .net runtime version .
Test project {name} does not reference any .NET NuGet adapter. Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
Disabling the option indicated below made everything work:
I found this solution after browsing the preview release notes at https://learn.microsoft.com/en-us/visualstudio/releasenotes/vs2017-preview-relnotes#--visual-studio-2017-version-158-preview-4 (scroll down to "... What's New ..." and then .NET Test Adapter Extension). It mentions this breaking change (though it didn't break my other projects), but there is no mention of what to actually do to solve the problem.
Of course, long-term, keeping that option unchecked doesn't seem feasible. So I am looking for guidance on how to proceed.
I already tried to see if I could "quickly" upgrade to MSTest v2, but that had an issue because System.Runtime 4.1.2 couldn't be found. I tried adding System.Runtime 4.3.0 via NuGet, but that didn't solve the issue.
I was getting a similar issue running Xamarin.UITests and resolved it by installing the "NUnit 2 Test Adapter" Extension in Visual Studio. In Visual Studio 2017 you do this from Tools > > Extensions and Updates... > Online > Search "NUnit Adapter" > click the NUnit 2 Test Adapter then the Download button to install. Restart Visual Studio when prompted to complete the installation.
It would be interesting to understand how the MSTest V1 framework assembly(Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll) is referenced in this project. The compatibility checkbox that also ended up being disabled in the image above should ensure that this project has MSTestV1 tests and enabled run tests. If it isn't then for some reason the detection logic is busted and needs to be fixed - a snippet on how the assembly is referenced would be helpful there.
As for moving to MSTest V2, this blog should help: https://blogs.msdn.microsoft.com/devops/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/ . And for the specific issue you seem to be running into, this github issue on the repo sounds similar: https://github.com/Microsoft/testfx/issues/184 .
Caltor's answer pretty much solved it for me: it was the NUnit Adapter I needed. But I followed slightly different steps. Here they are for VS 2019 (but probably apply to VS 17 too):
Right clicked on the References node under my project in the solution explorer
Chose "Manager NuGet packages"
Clicked Browse
Searched for nunit3testadapter
Hit install on the result that popped up
The issue for me was similar to the OP's - the adapter was installed on some projects but not others. But confusingly this wasn't immediately visible under the "References" node for that project. The only node relating to nunit under that References node said "nunit.framework". So the references for test with and without the adapter looked the same.
"... but that had an issue because System.Runtime 4.1.2 couldn't be found."
I think this is a setting in the app.config that does not get updated when the project settings are updated. I searched for System.Runtime under the packages folder and then changed my app.config to match what I found, and then that particular problem went away.
cannot start .NET Core app because of this error:
"It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.0.7' was not found.
- Check application dependencies and target a framework version installed at:
\
- Alternatively, install the framework version '2.0.7'.
The program '[1560] dotnet.exe' has exited with code -2147450749 (0x80008083)."
Editing .csproj didn't help. It looks like this:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.7</RuntimeFrameworkVersion>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
You don't have the right .NET Core runtime installed. It's not good enough that's a .NET Core 2 runtime; it needs to be a minor version that is equal to or encompasses the version you're trying to target. You can see all the available runtimes here: https://www.microsoft.com/net/download/all. Specifically, you need 2.0 Runtime (v2.0.7) or higher. You can just choose 2.1, though. 2.0.7 will be rolled in and then, if you do end up upgrading your project later, you won't run into this issue again.
After playing around for a (longer) while, eventually it turned out that the solution is to comment out RuntimeFrameworkVersion in .csproj:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<!--<RuntimeFrameworkVersion>2.0.7</RuntimeFrameworkVersion>-->
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
It is worth mentioning that the problem occured after my collegues upgraded a .NET Core to higher version and I did 'Get latest version'.
i have some problems regarding building .NET solution for handheld device using NAnt 0.92. The solution consists of typical csproj and CAB installer (vddproj). The target platform is .NET CF 3.5.
However, if i set the target platform in the script as:
< property name="nant.settings.currentframework" value="netcf-3.5" />
when i execute then i receive an error:
Target framework could not be changed. "netcf-3.5" is not a valid framework identifier.
This means that i cannot build solutions for target platform 3.5. Logically, i have tried with CF 2.0 afterwards:
< property name="nant.settings.currentframework" value="netcf-2.0" />
and then i receive an error
Failed to initialize the 'Microsoft .NET Compact Framework 2.0' (netcf-2.0) target framework. Registry path not found! - key = 'SOFTWARE\MICROSOFT......'
I have the proper SDK installed as some other posts suggested. Also, tried to disable the antivirus, as also suggested in similar posts, but couldn't find any solution.
Can you give any advice, please?
Thank you in advance. Daniel
I know it's a bit late but I would suggest that you're using NAnt only to trigger MSBuild.exe. Thats what we're doing in our CI environment and it works perfectly. Also make sure that your project is a smart device project or else it won't build correctly. I'm not even sure if NAnt supports the CF 3.5 (anymore).
I know how to integrate MSpec with R#, I'm aware of "blocked DLLs" problem. But I still can't figure out why my tests are not recognized. I'm integrating MSpec in an unusual way though. I do not use NuGet. I have old MSpec build - 0.4.9 - which my tests are built for. I manually create Plugins folder for R# and put the following DLLs there:
Machine.Specifications.dll 0.4.9
Machine.Specifications.ReSharperRunner.6.1.dll 0.5.0 (built from GitHub sources)
After I start VS and open R#'s options dialog the runner is displayed in the Plugins section. But my tests are not recognized. Can the version mismatch be an issue? Does R# have any logging where I can see its communication with the plugin?
Did you try to download the 0.4.9 binaries from NuGet and use the ReSharper runner from this release? The current source doesn't support these old versions anymore.
I have finally sorted that out. I had to debug the runner as described here - https://github.com/machine/machine.specifications/blob/master/debugging-resharper.txt. And I found out that the runner was built for ReSharper 6.1.37.86, which is not the latest 6.1 release, list is here - http://resharper-support.jetbrains.com/entries/21206508-Where-can-I-download-an-old-previous-ReSharper-version-. The latest 6.1 release is 6.1.1000.82 which is installed on my machine. So the runner just could not find required ReSharper assemblies during startup. I fixed the problem by adding assembly redirects into devenv's config file. The redirects are needed for all ReSharper files the runner depends upon, there are 16 of them in total. Example redirect is:
<dependentAssembly>
<assemblyIdentity name="JetBrains.Platform.ReSharper.ComponentModel" publicKeyToken="1010a0d8d6380325" culture="neutral"/>
<bindingRedirect oldVersion="6.1.37.86" newVersion="6.1.1000.82"/>
</dependentAssembly>
For anyone coming at this problem with a Visual Studio 2019 / Resharper 2019.3.4+ setup, what worked is using Resharper's inbuilt extensions manager.
In VS, go to:
Extensions -> ReSharper -> Extension Manager
and search/install "Machine.Specifications for ReSharper"