[英]How to compile F# in any version on mac?
(I am aware of the existing stack overflow question How to use F# 4.7 on Mac? that is very similar, but not identical, and that have no solution yet) (我知道现有的堆栈溢出问题如何在 Mac 上使用 F# 4.7?这非常相似,但不完全相同,还没有解决方案)
On my mac (catalina 10.15.7) I installed the .NET core via this link with no issues.在我的 mac(catalina 10.15.7)上,我通过此链接安装了 .NET 核心,没有任何问题。
The command命令
dotnet --help
correctly returns the help.正确返回帮助。
When trying to initialise a new project, it fails with:尝试初始化新项目时,失败并显示:
$ dotnet new –lang f#
Getting ready...
Couldn't find an installed template that matches the input, searching online for one that does...
No templates found matching: '–lang'.
$ dotnet new --lang "f#"
Invalid input switch:
--lang
f#
Run dotnet new --help for usage information.
See https://aka.ms/dotnet-install-templates to learn how to install additional template packs.
So how do I start a project or run a F# file on mac?那么如何在 Mac 上启动项目或运行 F# 文件? Is there any up to date blog post providing a tutorial for installing an F# compiler?
是否有最新的博客文章提供安装 F# 编译器的教程?
----- EDIT ----- - - - 编辑 - - -
The command dotnet new
returns:命令
dotnet new
返回:
$ dotnet new
Templates Short Name Language Tags
-------------------------------------------- -------------- ------------ ----------------------
Console Application console [C#], F#, VB Common/Console
Class library classlib [C#], F#, VB Common/Library
Worker Service worker [C#], F# Common/Worker/Web
Unit Test Project mstest [C#], F#, VB Test/MSTest
NUnit 3 Test Project nunit [C#], F#, VB Test/NUnit
NUnit 3 Test Item nunit-test [C#], F#, VB Test/NUnit
xUnit Test Project xunit [C#], F#, VB Test/xUnit
Razor Component razorcomponent [C#] Web/ASP.NET
Razor Page page [C#] Web/ASP.NET
MVC ViewImports viewimports [C#] Web/ASP.NET
MVC ViewStart viewstart [C#] Web/ASP.NET
Blazor Server App blazorserver [C#] Web/Blazor
Blazor WebAssembly App blazorwasm [C#] Web/Blazor/WebAssembly
ASP.NET Core Empty web [C#], F# Web/Empty
ASP.NET Core Web App (Model-View-Controller) mvc [C#], F# Web/MVC
ASP.NET Core Web App webapp [C#] Web/MVC/Razor Pages
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
ASP.NET Core with React.js and Redux reactredux [C#] Web/MVC/SPA
Razor Class Library razorclasslib [C#] Web/Razor/Library
ASP.NET Core Web API webapi [C#], F# Web/WebAPI
ASP.NET Core gRPC Service grpc [C#] Web/gRPC
dotnet gitignore file gitignore Config
global.json file globaljson Config
NuGet Config nugetconfig Config
Dotnet local tool manifest file tool-manifest Config
Web Config webconfig Config
Solution File sln Solution
Protocol Buffer File proto Web/gRPC
Examples:
dotnet new mvc --auth Individual
dotnet new web
dotnet new --help
dotnet new classlib --help
Watch out for formatting when copying from web sites从 web 站点复制时注意格式
The dash in the question's –lang
isn't the minus character -
, it's an en dash .问题的
–lang
中的破折号不是减号-
,它是一个破折号。 I suspect you copied the command from a web site that replaced the minus character with an en dash.我怀疑您从 web 站点复制了该命令,该站点将减号字符替换为破折号。 This is similar to sites replacing
"
or '
with typography quotes.这类似于用排版引号替换
"
或'
网站。
Type the command directly instead of pasting it.直接键入命令而不是粘贴它。
Original Answer原始答案
new
has no --lang
option. new
没有--lang
选项。 Try -lang
or --language
to list all available templates for a language.尝试
-lang
或--language
列出一种语言的所有可用模板。 To specify f#
type f#
eg:要指定
f#
类型f#
例如:
> dotnet new -lang f#
These templates matched your input: language='f#'.
Templates Short Name Language Tags
-------------------------- ---------- -------- -----------------
Console Application console F# Common/Console
Class library classlib F# Common/Library
Worker Service worker F# Common/Worker/Web
Unit Test Project mstest F# Test/MSTest
NUnit 3 Test Project nunit F# Test/NUnit
NUnit 3 Test Item nunit-test F# Test/NUnit
xUnit Test Project xunit F# Test/xUnit
ASP.NET Core Empty web F# Web/Empty
ASP.NET Core Web App (M... mvc F# Web/MVC
ASP.NET Core Web API webapi F# Web/WebAPI
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.