Skip to content

Could not load file or assembly 'TechTalk.SpecFlow' #107

@icnocop

Description

@icnocop

I'm getting the following compilation error message:

C:\Builds\1\1\src\MySolution\packages\SpecFlow.2.0.0\tools\TechTalk.SpecFlow.targets(47,5): error : Could not load file or assembly 'TechTalk.SpecFlow, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41' or one of its dependencies. The system cannot find the file specified. [C:\Builds\1\1\src\MySolution\MySpecFlowProject\MySpecFlowProject.csproj]

This issue only happens randomly, using MSBuild 14.0 (on a Visual Studio 2015 solution\project), and SpecFlow 2.0, even after removing the project reference to TechTalk.SpecFlow.Generator as indicated here.

MySpecFlowProject referenced NuGet packages (packages.config):

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="SpecBind" version="1.7.1.272" targetFramework="net45" />
  <package id="SpecBind.CodedUI" version="1.7.1.272" targetFramework="net45" />
  <package id="SpecBindGeneratorPlugin.SpecFlow" version="1.7.1.272" targetFramework="net45" />
  <package id="SpecFlow" version="2.0.0" targetFramework="net45" />
  <package id="SpecFlow.CustomPlugin" version="2.0.0" targetFramework="net45" />
  <package id="SpecFlow.MsTest" version="2.0.0" targetFramework="net45" />
</packages>

MySpecFlowProject project references:

    <Reference Include="SpecBind, Version=1.7.1.272, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\SpecBind.1.7.1.272\lib\net45\SpecBind.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="SpecBind.CodedUI, Version=1.7.1.272, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\SpecBind.CodedUI.1.7.1.272\lib\net45\SpecBind.CodedUI.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="TechTalk.SpecFlow, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41, processorArchitecture=MSIL">
      <HintPath>..\packages\SpecFlow.2.0.0\lib\net45\TechTalk.SpecFlow.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="TechTalk.SpecFlow.Parser, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41, processorArchitecture=MSIL">
      <HintPath>..\packages\SpecFlow.CustomPlugin.2.0.0\lib\net45\TechTalk.SpecFlow.Parser.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="TechTalk.SpecFlow.Utils, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41, processorArchitecture=MSIL">
      <HintPath>..\packages\SpecFlow.CustomPlugin.2.0.0\lib\net45\TechTalk.SpecFlow.Utils.dll</HintPath>
      <Private>True</Private>
    </Reference>

MySpecFlowProject.csproj includes TechTalk.SpecFlow.targets as follows:

<Import Project="..\packages\SpecFlow.2.0.0\tools\TechTalk.SpecFlow.targets" />

MySpecFlowProject's App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
    <generator allowDebugGeneratedFiles="true" />
    <stepAssemblies>
      <stepAssembly assembly="MyOtherStepAssembly" />
    </stepAssemblies>
    <plugins>
      <add name="SpecBindGeneratorPlugin" path="..\packages\SpecBindGeneratorPlugin.SpecFlow.1.7.1.272\tools" type="Generator" />
    </plugins>
    <unitTestProvider name="MsTest" />
  </specFlow>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="TechTalk.SpecFlow" publicKeyToken="0778194805d6db41" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

The build directory is always cleaned before a build.
This only started happening when I added a NuGet reference to SpecBind.CodedUI.
SpecBind.CodedUI, Version=1.7.1.272 references TechTalk.SpecFlow, Version=2.0.0.0.
There are two feature files in the project and their Custom Tool property is set to SpecFlowSingleFileGenerator.
Builds and rebuilds work fine in Visual Studio 2015, just not during automated / continuous integration (CI) builds.

I'm wondering if there's a way to explicitly indicate the path of where to look for TechTalk.SpecFlow.dll or something similar?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions