1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【環境構築】PowerShell上でC#やF#のスクリプトをコンパイルする

Last updated at Posted at 2023-12-20

目標

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にこれらのパスを追加します。

image.png

注意

Visual Studio にF#がインストールされていない場合は先にインストールしてください。
以下のリンクなどが参考になると思います。

以上です!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?