I'm getting the following error seemingly randomly when I try generate my .feature files.
Occasionally I change or alter my feature file, and this error crops up out of nowhere:
#error Generation error: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I have absolutely no idea how to solve this - I have tried adding a reference to the assembly, changing versions of SpecFlow / NUnit but nothing seems to work.
Erasing my copy of the project and pulling it from source control works initially but then it happens again.
Here is a full list of my installed packages:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net461" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.Data.Edm" version="5.8.2" targetFramework="net461" />
<package id="Microsoft.Data.OData" version="5.8.2" targetFramework="net461" />
<package id="Microsoft.Data.Services.Client" version="5.8.2" targetFramework="net461" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
<package id="NUnit" version="3.0.0" targetFramework="net461" />
<package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net461" />
<package id="SpecFlow" version="2.2.1" targetFramework="net461" />
<package id="SpecFlow.NUnit" version="2.2.1" targetFramework="net461" />
<package id="System.ComponentModel.EventBasedAsync" version="4.0.11" targetFramework="net461" />
<package id="System.Dynamic.Runtime" version="4.0.0" targetFramework="net461" />
<package id="System.Linq.Queryable" version="4.0.0" targetFramework="net461" />
<package id="System.Net.Requests" version="4.0.11" targetFramework="net461" />
<package id="System.Spatial" version="5.8.2" targetFramework="net461" />
<package id="WindowsAzure.Storage" version="8.6.0" targetFramework="net461" />
</packages>
I'm running Visual Studio Community 17 (15.5.2), .NET 4.7.02556 and the SpecFlow extension version 2017.1.10
Especially while installing a new dev machine, and building your project for the first time, you may end up getting the following exception: Could not load file or assembly ‘ [assemblyname]’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
Especially while installing a new dev machine, and building your project for the first time, you may end up getting the following exception: Could not load file or assembly ‘[assemblyname]’ or one of its dependencies. An attempt was made to load a program with an incorrect format. No fear, though, as this is usually easily fixed.
An attempt was made to load a program with an incorrect format. No fear, though, as this is usually easily fixed. In quite a few cases, it’s simply a mismatch between architectures and easily changed. The latter part of the error message should point you to the right direction.
What sometimes works for me is deleting the packages
folder from the solution path, then restore nuget packages in solution and regenerate the feature files.
Sometimes this is not enough, and you also have to delete the visual studio cache.
Which is located: %LOCALAPPDATA%/Microsoft/Visual Studio/<your VS version>/ComponentModelCache
This is a known issue, which we couldn't yet reproduce and fix.
GitHub Issue: https://github.com/techtalk/SpecFlow/issues/857
It's a Microsoft package issue. This solution worked for me. Issue disappeared and now builds successfully.
In your Azure Build Pipeline
> NuGet tool installer
step, change Version of NuGet.exe to install
to a newer version, like 5.4.0.
Check Nuget's latest ReleasedAndBlessed
version at https://dist.nuget.org/tools.json.
The fix for me was to remove the existing .feature.cs
file(s) and then regenerate them.
I'm using Visual Studio 2017 15.5.1 and the following SpecFlow versions:
SpecFlow Version:2.2.0.0
SpecFlow Generator Version:2.2.0.0
The followin github thread, gave me the clues:
Visual Studio 2017 Generation error: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With