我正在尝试将 F# ASP.NET Core 应用部署到 Azure 应用服务。不幸的是,每次我尝试部署时,都会出现 <UserSecretsId>
元素已添加到我的项目文件中,如所解释的 in this article导致构建失败并出现以下错误:
A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence
本文解释了发生错误的原因,并指示通过从项目文件中删除该元素并在 AssemblyInfo.fs
中添加用户 secret ID 来修复该错误。 。我已经尝试过这个,然后可以手动构建,但是每次我尝试部署时,部署过程仍然会添加 <UserSecretsId>
我的项目文件中具有新 ID 的元素,导致构建失败。
有什么方法可以将 F# ASP.NET Core 应用程序发布到 Azure 应用服务吗?
最佳答案
将其添加到您的 .fsproj 文件中以抑制属性生成。
<PropertyGroup>
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
</PropertyGroup>
如果您想使用用户 secret ,则需要手动添加 UserSecrets 程序集属性。
module Your.Namespace.AssemblyInfo
open Microsoft.Extensions.Configuration.UserSecrets
[<assembly: UserSecretsIdAttribute("Your UserSecretsId")>]
do()
此外,在 ASP.NET Core 2.2 中应该不需要此解决方法。请参阅https://github.com/aspnet/Configuration/pull/872
关于azure - UserSecretsId 阻止将 F# ASP.NET Core 应用程序部署到 Azure 应用服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51979892/