Specflow插件:生成错误:缺少[assembly:GeneratorPlugin]属性

7
我正在编写一个自定义插件,以定制SpecFlow生成的自动生成代码文件。在构建解决方案并将其放置在SpecFlow测试项目的“lib”文件夹中之后,在保存SpecFlow特性文件时,我会得到以下信息:
Specflow plugin : Generation error: Missing [assembly:GeneratorPlugin] attribute in 'path to dll'

虽然我已经在插件程序集中标记了这个

[assembly: GeneratorPluginAttribute(typeof(CustomGeneratorPlugin))]

使用反射/自测试,我可以加载程序集并解析属性。

代码在这里 -- https://github.com/chrismckelt/SpecFlowCustomPlugin

有什么想法是什么导致了这个问题吗?谢谢。


1
程序集版本控制?您确定属性的类型是否与由SpecFlow插件主机在运行时定义的程序集完全相同的引用? - AlSki
1
如果你真的卡住了,你可以从 https://github.com/techtalk/SpecFlow 编译自己的 SpecFlow 版本,并在记录错误之前添加 Debugger.Launch() 吗?或者只需使用 devenv 调试加载插件的 devenv? - AlSki
嗨,是的,我执行了Debugger.Launch - 但由于它是通过VS扩展运行的,所以出现了一些问题 - 更改VS SpecFlow dlls会导致各种问题(它们是否已签名?)并且必须在VS中进行卸载/重新安装。 - Chris McKelt
也考虑了版本问题。重新编译使用与 VS SpecFlow 扩展程序 1.9.2.1 相同的版本,但没有成功。如果有人知道这是否有效,很乐意再尝试通过 Visual Studio 扩展程序进行调试。 - Chris McKelt
1
你可以尝试联系 Gaspar Nagy 寻求关于在调试模式下运行它的建议 (http://stackoverflow.com/users/26530/gaspar-nagy)。 - AlSki
2个回答

3

通过在生成器SpecFlow配置部分添加下面的“路径”属性来解决

<generator path=".\lib" 

完整配置
<specFlow>
    <generator allowDebugGeneratedFiles="false" allowRowTests="true" generateAsyncTests="false" path=".\lib" />
    <runtime stopAtFirstError="false" missingOrPendingStepsOutcome="Ignore" />
    <trace traceSuccessfulSteps="true" traceTimings="false" minTracedDuration="0:0:0.1" stepDefinitionSkeletonStyle="RegexAttribute" />
    <plugins>
        <add name="McKeltCustom" path=".\lib" type="GeneratorAndRuntime" />
    </plugins>
    <stepAssemblies>
        <stepAssembly assembly="SpecFlow.Assist.Dynamic" />
    </stepAssemblies>
</specFlow>

0
我通过将SpecflowPlugin项目中所有引用的TechTalk.SpecFlow dlls的复制本地标志设置为false来解决了这个问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接