将 Microsoft.Bot.Builder.LanguageGeneration 升级到 4.15.0 会导致 fromFile() 错误

Upgrading Microsoft.Bot.Builder.LanguageGeneration to 4.15.0 results in fromFile() error

Microsoft.Bot.Builder.LanguageGeneration4.14.1 升级到 4.15.0 会导致有关 fromFile() 方法的新错误。尚未在互联网上找到任何解决方案或类似问题。这使我们无法升级,因此欢迎任何反馈。

/UnitTests/bin/Debug/net5.0/Resources/Lg/General.lg line 25:2 - line 25:39: Error occurred when parsing expression 'fromFile('../Cards/HelpCard.json')'. fromFile does not have an evaluator, it's not a built-in function or a custom function.

This release introduces a global flag called "Templates.EnableFromFile" that indicates whether the Adaptive Expression fromFile function is allowed in LG templates. If an application had previously made use of this function, it is now required to add the line "Templates.EnableFromFile = true;" to the Startup.cs code.

来自 botbuilder-dotnet/releases

将它添加到 Startup.cs(或 Program.cs)中没有帮助。我不得不把它放在我使用 Templates class.

的服务的构造函数中

对于需要如何添加示例的人。

在startup.cs->ConfigureServices方法中这样添加。

还有 lg 文件 - 您不必手动创建 lg 文件 - 它会在后端生成。

您只需在机器人响应中添加您的内容,即它将在后端 lg 文件中生成的内容 - 您可以在 visual studio 中打开相同的解决方案并查看它。