Làm thế nào để biên dịch F # trong bất kỳ phiên bản nào trên mac?

Jan 04 2021

(Tôi biết câu hỏi tràn ngăn xếp hiện có Làm thế nào để sử dụng F # 4.7 trên Mac? Điều đó rất giống, nhưng không giống nhau và chưa có giải pháp nào)

Trên máy mac của tôi (catalina 10.15.7), tôi đã cài đặt lõi .NET qua liên kết này mà không gặp vấn đề gì.

Lệnh

dotnet --help

trả lại chính xác sự trợ giúp.

Khi cố gắng khởi tạo một dự án mới, nó không thành công với:

$ 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.

Vậy làm cách nào để bắt đầu một dự án hoặc chạy tệp F # trên mac? Có bài đăng blog cập nhật nào cung cấp hướng dẫn cài đặt trình biên dịch F # không?

----- BIÊN TẬP -----

Lệnh dotnet newtrả về:

$ 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

Trả lời

3 PanagiotisKanavos Jan 04 2021 at 21:21

Chú ý định dạng khi sao chép từ các trang web

Dấu gạch ngang trong câu hỏi –langkhông phải là ký tự trừ -, mà là dấu gạch ngang . Tôi nghi ngờ bạn đã sao chép lệnh từ một trang web đã thay thế ký tự dấu trừ bằng dấu gạch ngang. Điều này tương tự như các trang web thay thế "hoặc 'bằng các trích dẫn kiểu chữ.

Nhập lệnh trực tiếp thay vì dán nó.

Câu trả lời gốc

newkhông có --langtùy chọn. Thử -langhoặc --languageliệt kê tất cả các mẫu có sẵn cho một ngôn ngữ. Để chỉ định f#loại f#ví dụ:

> 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