2
3

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 3 years have passed since last update.

.NetFramework付属のコンパイラだけで実行ファイルを作る をしてみた。

Last updated at Posted at 2020-05-11

コンパイラ

csc.exe : c#
vbc.exe : vb.net
jsc.exe : JScript.net

コンパイル

ソースコードは hello.cs で確認。

comple.bat
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe ^
 hello.cs

これをダブルクリックで hello.exe が生成されました。
5KBとは小さい!

スクリーンショット_2020-05-11_09-12-26.png

実行すると、大きめの黒い窓と共に表示される。

スクリーンショット_2020-05-11_09-13-06.png

大きめの黒い窓を消すには /target:winexe オプションを指定する。

csc.exe /target:winexe hello.cs

コマンドプロンプトにPATHを渡す

setenv.bat
@echo off
PATH="%WINDIR%\Microsoft.NET\Framework\v1.0.3705";%PATH%
PATH="%WINDIR%\Microsoft.NET\Framework\v1.1.4322";%PATH%
PATH="%WINDIR%\Microsoft.NET\Framework\v2.0.50727";%PATH%
PATH="%WINDIR%\Microsoft.NET\Framework\v3.0";%PATH%
PATH="%WINDIR%\Microsoft.NET\Framework\v3.5";%PATH%
PATH="%WINDIR%\Microsoft.NET\Framework\v4.0.30319";%PATH%
cmd

ここからcsc.exeがすぐに呼べる。

comple_js.bat
@echo off
PATH="%WINDIR%\Microsoft.NET\Framework\v4.0.30319";%PATH%

cd %~dp0

rem 引数無し実行はエラー
if "%~1"=="" (
  echo "[quit] Drug and drop a .js file."
  timeout 5
  exit
)

echo "[info] comple.."
jsc %1
timeout 5

参照設定

csc.exe ^
 /reference:MyDLL_1.dll ^
 /platform:x86 ^
 /target:winexe ^
 hello.cs

jsc.exe

hello.js
print("Hello,World");
コンパイル
jsc.exe hello.js

# 実行
hello.exe

その他参考

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?