F#ASP.NET核心项目:EntryPointAttribute错误

问题描述 投票:4回答:1

这是我的ASP.NET Core Web API入口点:

open Microsoft.AspNetCore
open Microsoft.AspNetCore.Hosting

module Hosting =
    let BuildWebHost args =
        WebHost
            .CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .UseIISIntegration()
            .Build()

module Program =
    let [<EntryPoint>] main args = Hosting.BuildWebHost(args).Run(); 0

这是来自Program.fs,我项目的最终文件。

经过几个月的顺利编译,我突然遇到以下编译失败:

错误FS0433:标有“EntryPointAttribute”属性的函数必须是编译序列中最后一个文件中的最后一个声明。

这是最后一个文件中的最后一个声明 - 任何想法为什么现在可能会突然失败?

asp.net-core f#
1个回答
3
投票

这是因为用户机密基础结构将文件注入为程序集中的最后一个文件。它在F#的下一个版本中修复:请参阅https://github.com/aspnet/Configuration/issues/833

这里有一个解决方法:https://medium.com/@dmytrol/making-asp-net-core-user-secrets-work-in-f-projects-9b04572d81f6,您可以在其中设置代码库中的用户秘密ID,而不是在项目文件中。

© www.soinside.com 2019 - 2024. All rights reserved.