首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Specflow - GenerateFeatureFileCodeBehindTask意外失败

Specflow - GenerateFeatureFileCodeBehindTask意外失败
EN

Stack Overflow用户
提问于 2020-03-19 18:36:33
回答 7查看 9K关注 0票数 15

我对SpecFlow有个问题。我们正在使用Azure Devops,当我在我的本地机器上构建解决方案时,它工作得很好,但在Azure Devops构建期间,我得到了以下错误:

代码语言:javascript
复制
[error]C:\Windows\ServiceProfiles\NetworkService\.nuget\packages\specflow.tools.msbuild.generation\3.1.86\build\SpecFlow.Tools.MsBuild.Generation.targets(93,5): Error MSB4018: The "GenerateFeatureFileCodeBehindTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'TechTalk.SpecFlow, Version=3.1.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41'. The system cannot find the file specified.
File name: 'TechTalk.SpecFlow, Version=3.1.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41'
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType)
   at TechTalk.SpecFlow.Generator.Plugins.GeneratorPluginLoader.LoadPlugin(PluginDescriptor pluginDescriptor)
   at TechTalk.SpecFlow.Generator.GeneratorContainerBuilder.LoadPlugins(ObjectContainer container, GeneratorPluginEvents generatorPluginEvents, UnitTestProviderConfiguration unitTestProviderConfiguration, IEnumerable`1 generatorPlugins)
   at TechTalk.SpecFlow.Generator.GeneratorContainerBuilder.CreateContainer(SpecFlowConfigurationHolder configurationHolder, ProjectSettings projectSettings, IEnumerable`1 generatorPluginInfos, IObjectContainer parentObjectContainer)
   at SpecFlow.Tools.MsBuild.Generation.WrappedGeneratorContainerBuilder.BuildGeneratorContainer(SpecFlowConfigurationHolder specFlowConfigurationHolder, ProjectSettings projectSettings, IReadOnlyCollection`1 generatorPluginInfos, IObjectContainer rootObjectContainer)
   at SpecFlow.Tools.MsBuild.Generation.GenerateFeatureFileCodeBehindTaskExecutor.Execute()
   at SpecFlow.Tools.MsBuild.Generation.GenerateFeatureFileCodeBehindTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
代码语言:javascript
复制
        <PackageReference Include="FluentAssertions" Version="5.10.2" />
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
        <PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
        <PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
        <PackageReference Include="NUnit" Version="3.12.0" />
        <PackageReference Include="Selenium.Support" Version="3.141.0" />
        <PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
        <PackageReference Include="SpecFlow" Version="3.1.86" />
        <PackageReference Include="SpecFlow.MsTest" Version="3.1.86" />
        <PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.86" />

我试过在nUnitMsTestxUnit上使用它,但总是失败。目标框架:.NET核心3.1。构建代理: vs2019-win2019

EN

回答 7

Stack Overflow用户

发布于 2020-03-25 00:01:11

我们也遇到过同样的问题,经过更长时间的挖掘,我发现在他们的git repo https://github.com/SpecFlowOSS/SpecFlow/issues/1912中有一个为此而创建的问题。引用自git问题:

MSBuild 16.5为可能有副作用的任务提供了一种新的程序集加载方法。你可以尝试设置MSBUILDSINGLELOADCONTEXT=1 (env var)来获得旧的行为。

尝试在您的构建管道中将其设置为:

代码语言:javascript
复制
 variables:
    ...
    MSBUILDSINGLELOADCONTEXT: '1'
    ...

这对我们的情况很有帮助。

编辑:此问题似乎已在较新版本的SpecFlow (3.3.15+)中修复。

票数 14
EN

Stack Overflow用户

发布于 2020-03-24 16:41:32

也有同样的问题,原来是.net核心软件开发工具包和Specflow之间的版本问题。我们将.net核心软件开发工具包降级到3.1.102,这对我们很有帮助

票数 4
EN

Stack Overflow用户

发布于 2020-09-17 21:01:27

从SpecFlow 2迁移后,SpecFlow 3.4.8也出现了同样的问题。

After version SpecFlow 3.3.30 don’t need to add the SpecFlow.Tools.MSBuild.Generation package anymore以来

所以我删除了SpecFlow.Tools.MSBuild.Generation包,但是问题仍然存在。

在那之后,我将specflow.json添加到测试项目中,问题就消失了。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60755395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档