SpecFlow.VS icon indicating copy to clipboard operation
SpecFlow.VS copied to clipboard

InvokeDiscovery: fails for .NET Core 6.0

Open GeorgeNwador opened this issue 4 years ago • 7 comments

I am trying to create a new project using .NET Core 6.0 and SpecFlow 3.9.40 on Visual Studio 2022 but my feature file is not binding with my class file. And I receive an error message within VS output window whenever I click on SpecFlow's Find Step Definition Usage.

Here is the full output:

Info: OnActivityStarted: Starting Visual Studio Extension... Info: CreateProjectScope: Initializing project: TestFramework Info: OnSettingsInitialized: Project settings initialized: .NETCoreApp,Version=v6.0,SpecFlow:3.9.40 Warning: InvokeDiscovery: Error during binding discovery. Command executed: C:\Users\svk4\source\repos\TestFramework\TestFramework\bin\Debug\net6.0> C:\Program Files\dotnet\dotnet.exe exec C:\USERS\SVK4\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\17.0_D8640198\EXTENSIONS\IZUZW5YY.TCV\Connectors\V3-net6.0\specflow-vs.dll discovery C:\Users\svk4\source\repos\TestFramework\TestFramework\bin\Debug\net6.0\TestFramework.dll "" Exit code: 4 Message: Exception in:SpecFlow.VisualStudio.SpecFlowConnector.Discovery.V38.SpecFlowV38Discoverer Error: Exception has been thrown by the target of an invocation. -> Interface cannot be resolved: TechTalk.SpecFlow.UnitTestProvider.IUnitTestRuntimeProvider('nunit') Exception: System.Reflection.TargetInvocationException->BoDi.ObjectContainerException StackTrace: at BoDi.ObjectContainer.TypeRegistration.<>c__DisplayClass3_0.<ResolvePerContext>b__1() at BoDi.ObjectContainer.RegistrationWithStrategy.ExecuteWithLock(Object lockObject, Func1 getter, Func1 factory, ResolutionList resolutionPath) at BoDi.ObjectContainer.TypeRegistration.ResolvePerContext(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath) at BoDi.ObjectContainer.RegistrationWithStrategy.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath) at BoDi.ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath) at BoDi.ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name) at BoDi.ObjectContainer.Resolve(Type typeToResolve, String name) at BoDi.ObjectContainer.Resolve[T](String name) at TechTalk.SpecFlow.Infrastructure.ContainerBuilder.CreateGlobalContainer(Assembly testAssembly, IRuntimeConfigurationProvider configurationProvider) at SpecFlow.VisualStudio.SpecFlowConnector.Discovery.SpecFlowV3BaseDiscoverer.CreateGlobalContainer(IConfigurationLoader configurationLoader, Assembly testAssembly) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.V3\Discovery\SpecFlowV3BaseDiscoverer.cs:line 36 at SpecFlow.VisualStudio.SpecFlowConnector.Discovery.SpecFlowV3BaseDiscoverer.GetBindingRegistry(Assembly testAssembly, String configFilePath) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.V3\Discovery\SpecFlowV3BaseDiscoverer.cs:line 25 at SpecFlow.VisualStudio.SpecFlowConnector.Discovery.BaseDiscoverer.DiscoverInternal(Assembly testAssembly, String testAssemblyPath, String configFilePath) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector\Discovery\BaseDiscoverer.cs:line 13 at SpecFlow.VisualStudio.SpecFlowConnector.Discovery.BaseDiscoverer.Discover(Assembly testAssembly, String testAssemblyPath, String configFilePath) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector\Discovery\BaseDiscoverer.cs:line 57 at SpecFlow.VisualStudio.SpecFlowConnector.Discovery.VersionSelectorDiscoverer.Discover(Assembly testAssembly, String testAssemblyPath, String configFilePath) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.V3\Discovery\VersionSelectorDiscoverer.cs:line 25 at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at SpecFlow.VisualStudio.SpecFlowConnector.ReflectionExtensions.ReflectionCallMethod[T](Object obj, String methodName, Type[] parameterTypes, Object[] args) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector\ReflectionExtensions.cs:line 29 at SpecFlow.VisualStudio.SpecFlowConnector.Discovery.ReflectionSpecFlowDiscoverer.Discover(Assembly testAssembly, String testAssemblyPath, String configFilePath) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.V3\Discovery\ReflectionSpecFlowDiscoverer.cs:line 21 at SpecFlow.VisualStudio.SpecFlowConnector.Discovery.DiscoveryProcessor.Process() in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.V2\Discovery\DiscoveryProcessor.cs:line 26 at SpecFlow.VisualStudio.SpecFlowConnector.DiscoveryCommand.Execute(String[] commandArgs) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector\DiscoveryCommand.cs:line 17 at SpecFlow.VisualStudio.SpecFlowConnector.ConsoleRunner.EntryPoint(String[] args) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector\ConsoleRunner.cs:line 23

Warning: InvokeDiscovery: The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled. Please check the error message above and report to https://github.com/SpecFlowOSS/SpecFlow.VS/issues if you cannot fix. Warning: GetStepDefinitionsAsync: Unable to get step definitions from project 'TestFramework', usages will not be found for this project. Warning: ShowProblem: User Notification: All steps have been defined in this file already. Warning: ShowProblem: User Notification: All steps have been defined in this file already. Warning: ShowProblem: User Notification: All steps have been defined in this file already. Warning: GetStepDefinitionsAsync: Unable to get step definitions from project 'TestFramework', usages will not be found for this project.

@gasparnagy

GeorgeNwador avatar Dec 10 '21 17:12 GeorgeNwador

@younggeezus This looks a bit like a regression, because I have seen such error earlier. We have made some changes in this part recently, so it would help a lot if you could try if the error is also reproducible with https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2021.0.200 . For that you have to uninstall the extension, download and execute the VSIX from the release attachments. (Be careful, VS will upgrade it back to the current version at one of the next restarts unless you uncheck the upgrade box.)

gasparnagy avatar Dec 13 '21 07:12 gasparnagy

@gasparnagy @patiqs I uninstalled the extension I had and got downloaded and installed the one you provide but I am still getting the same error. I am using Visual Studio 2022.. I wonder if that makes a difference

GeorgeNwador avatar Dec 13 '21 15:12 GeorgeNwador

@younggeezus thx. this is a useful information, we can better find the source of the problem.

This new extension works only for VS2022, so that is fine.

If you can easily make a project that can be used to reproduce the problem that would be also very useful. You can do that by removing all confidential details, but keep your dependencies and just add a dummy feature file. If that simplified project reproduces the problem as well, please attach it to this ticket as a zip.

gasparnagy avatar Dec 13 '21 16:12 gasparnagy

Hi @younggeezus, We released a new version yesterday. Can you check if you still face the issue? If the issue still exists the please share your .csproj if possible. I cannot reproduce the issue.

patiqs avatar Dec 17 '21 17:12 patiqs

It seems to be a nuget version conflict

patiqs avatar Dec 17 '21 17:12 patiqs

Upgrading the nuget packages helped with a similar issue: Please check here: https://github.com/SpecFlowOSS/SpecFlow.VS/issues/46

patiqs avatar Dec 18 '21 08:12 patiqs

I plan to fix this in the next release. Please help me to reproduce this issue locally on my laptop. The best would be if you can create and share a repo where the issue exists. Or I can give you write access to our investigation repo, where you can commit a sample. If this doesn't work, then I need the csproj content of your test project

patiqs avatar Jan 27 '22 08:01 patiqs