Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during binding discovery with x86 #61

Closed
mbendtsen opened this issue Jan 17, 2020 · 8 comments
Closed

Error during binding discovery with x86 #61

mbendtsen opened this issue Jan 17, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@mbendtsen
Copy link
Contributor

My project is set to x86 and when opening the feature file this error occurs:

Info: OnActivityStarted: Starting Deveroom...
Info: CreateProjectScope: Initializing project: SpecflowTest
Info: OnSettingsInitialized: Project settings initialized: .NETCoreApp,Version=v3.1,SpecFlow:3.1.78
Warning: InvokeDiscovery: Error during binding discovery. 
Command executed:
  C:\Users\xmibe\source\repos\SpecflowTest\SpecflowTest\bin\Debug> C:\Program Files\dotnet\dotnet.exe exec c:\users\xmibe\appdata\local\microsoft\visualstudio\16.0_fe6c80f3\extensions\xcdze53w.35h\Connectors\V3\deveroom-specflow-v3.dll discovery C:\Users\xmibe\source\repos\SpecflowTest\SpecflowTest\bin\Debug\SpecflowTest.dll ""
Exit code: 4
Message: 
Error: Could not load file or assembly 'SpecflowTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Exception: System.IO.FileLoadException
StackTrace:
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at McMaster.NETCore.Plugins.PluginLoader.LoadDefaultAssembly()
   at Deveroom.VisualStudio.SpecFlowConnector.Discovery.DiscoveryProcessor.Process() in W:\Deveroom\deveroom-visualstudio-prod\community\Deveroom.VisualStudio.SpecFlowConnector.V2\Discovery\DiscoveryProcessor.cs:line 33
   at Deveroom.VisualStudio.SpecFlowConnector.DiscoveryCommand.Execute(String[] commandArgs) in W:\Deveroom\deveroom-visualstudio-prod\community\Deveroom.VisualStudio.SpecFlowConnector\DiscoveryCommand.cs:line 17
   at Deveroom.VisualStudio.SpecFlowConnector.ConsoleRunner.EntryPoint(String[] args) in W:\Deveroom\deveroom-visualstudio-prod\community\Deveroom.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/specsolutions/deveroom-visualstudio/issues if you cannot fix.

If I run the command manuallly with the x86 version of dotnet, it works fine. Is there any way to control which dotnet version is used?

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsPackable>false</IsPackable>
    <Platforms>x86</Platforms>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
  </PropertyGroup>

  <PropertyGroup>
    <OutputPath>bin\$(Configuration)</OutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
    <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
    <PackageReference Include="coverlet.collector" Version="1.0.1" />
    <PackageReference Include="SpecFlow" Version="3.1.78" />
    <PackageReference Include="SpecFlow.MsTest" Version="3.1.78" />
    <PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.78" />
  </ItemGroup>

</Project>
@mbendtsen mbendtsen changed the title Error during binding discovery Error during binding discovery with x85 Jan 20, 2020
@mbendtsen mbendtsen changed the title Error during binding discovery with x85 Error during binding discovery with x86 Jan 20, 2020
@gasparnagy
Copy link
Contributor

I think this is a duplicate of #50.
@mbendtsen Could you please check if the workaround there with the deveroom.json config file solves the issue?

@mbendtsen
Copy link
Contributor Author

It doesn't. Maybe something change during these 6 month?

I have been looking at the code, and the as far as I can see the processor architecture is not used to determined the dotnet.exe version:

OutProcSpecFlowConnector.cs

private string GetDotNetInstallLocation()
{
    var programFiles = Environment.GetEnvironmentVariable("ProgramW6432");
    if (string.IsNullOrEmpty(programFiles))
        programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
    return Path.Combine(programFiles, "dotnet");
}

Could be changed to this:

private string GetDotNetInstallLocation()
{
    var programFiles = Environment.GetEnvironmentVariable("ProgramW6432");
    if (_configuration.ProcessorArchitecture == ProcessorArchitectureSetting.X86)
        programFiles = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
    if (string.IsNullOrEmpty(programFiles))
        programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
    return Path.Combine(programFiles, "dotnet");
}

@gasparnagy
Copy link
Contributor

@mbendtsen Makes sense. Is this the official way in .NET Core to run dotnet.exe in x86 mode? I mean that you have to run it from the Program Files (x86) folder? If yes, could you please send a pull request with the change you proposed?

@mbendtsen
Copy link
Contributor Author

@gasparnagy As far as I know, this is the way. We are using Win32 libraries and because of that we have to use x86 for platform and this gives us problem on our build server, where we had to use our own script to use the right dotnet.exe version. It seems like Visual Studio uses MSBuild which then uses dotnet.exe. For some reason this does not cause problems.

I have just made a test build of the solution, and the it solves my problem.

@gasparnagy
Copy link
Contributor

I will make a release tomorrow with this, thx.

@gasparnagy gasparnagy added the bug Something isn't working label Jan 22, 2020
@mbendtsen
Copy link
Contributor Author

@gasparnagy Not to push, but do you know when you will be making the release?

@gasparnagy
Copy link
Contributor

@mbendtsen push is good. I have forgotten about it, sorry. I do it now.

@gasparnagy
Copy link
Contributor

released. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants