[英]Using the new Package Reference syntax in F# scripts
According to this Microsoft blog post section, Package references in F# scripts , I should be able to use the following syntax in an fsx
script:根据 Microsoft 博客文章部分F# 脚本中的包引用,我应该能够在
fsx
脚本中使用以下语法:
#r "nuget: FSharp.Data"
Unfortunately, the compiler gives me the following error:不幸的是,编译器给了我以下错误:
The package management feature requires language version 5.0 use /langversion:preview F# Compiler(3302)
I believe I have dotnet.core 5.0
installed correctly:我相信我已经正确安装了
dotnet.core 5.0
:
dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.100
Commit: 5044b93829
Runtime Environment:
OS Name: Mac OS X
OS Version: 11.0
OS Platform: Darwin
RID: osx.11.0-x64
Base Path: /usr/local/share/dotnet/sdk/5.0.100/
Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7
.NET SDKs installed:
5.0.100-rc.1.20452.10 [/usr/local/share/dotnet/sdk]
5.0.100 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-downloa
How can I get this working correctly?我怎样才能让它正常工作? Currently, the
fsx
script inside a dotnet core solution if that makes any difference.目前,dotnet 核心解决方案中的
fsx
脚本有什么不同。 I'm using vscode with the ionide
plugin to write F#.我正在使用带有
ionide
插件的ionide
来编写 F#。
Ionide 尚不支持 F#5。
As Isaac Abraham pointed out in his answer, the Ionide
vscode package, at the time of this post, doesn't support F# 5.0 quite yet.正如 Isaac Abraham 在他的回答中指出的那样,在
Ionide
本文时, Ionide
vscode 包还不完全支持 F# 5.0。 However, the Ionide package helpfully does give the user the ability to enable a preview of F# 5.0 language features.但是,Ionide 包确实让用户能够启用 F# 5.0 语言功能的预览。
I fixed this compiler error by opening up the User's settings.json
file and adding the following lines:我通过打开用户的
settings.json
文件并添加以下行来修复此编译器错误:
"FSharp.fsiExtraParameters": [
"--langversion:preview"
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.