目標
PowerShell
> & csc .\Hello.fs
Microsoft (R) Visual C# Compiler バージョン 4.7.0-3.23416.8 (43b0b05c)
Copyright (C) Microsoft Corporation. All rights reserved.
> ./Hello
Hello, C# World!
PowerShell
> & fsc .\Hello.fs
Microsoft (R) F# Compiler バージョン F# 7.0 のための 12.7.0.0
Copyright (C) Microsoft Corporation. All rights reserved.
> ./Hello
Hello, F# World!
というようにコンパイルできるように設定します。
スクリプト
Hello.cs
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, C# World!");
}
}
Hello.fs
printfn "Hello F# World"
方法
Visual Studio 2022 Developer Command Prompt を立ち上げる
「Windows」キー+「Q」キーで検索窓を立ち上げて、「Developer Command Prompt」と入力します
whereコマンドを使って、csc.exeとfsc.exeのパスを特定します
Developer Command Prompt
>where csc
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\csc.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
Developer Command Prompt
>where fsc
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools\fsc.exe
「環境変数を編集」を開き、変数のPathにこれらのパスを追加します。
注意
Visual Studio にF#がインストールされていない場合は先にインストールしてください。
以下のリンクなどが参考になると思います。
以上です!