未指定時:EXE 取自含 Main 的檔名;DLL 取自第一個原始碼檔名。明確指定:
csc /out:Hello.exe HelloWorld.cs
編譯指定目錄及所有子目錄符合模式的 .cs 檔,支援萬用字元。
csc /target:library /out:dir2.dll /recurse:dir1\dir2\*.cs
引入指定組件的公用型別中繼資料。簡寫 /r。專案使用 using 導入的命名空間對應組件皆需參考,自訂類別庫同理。
csc /r:System.dll;MyExec.exe;MyLibrary.dll MyProject.cs
| 選項 | 輸出類型 | 說明 |
|---|---|---|
/target:exe | Console EXE | 主控台應用程式 |
/target:winexe | Windows EXE | GUI 應用程式(無主控台視窗) |
/target:library | DLL | 類別庫,無進入點 |
/target:module | Module (DLL) | 無組件資訊的模組,供 /addmodule 合併 |
csc /target:exe MyProj.cs
csc /target:winexe MyProject.cs
csc /target:library MyProject.cs
csc /target:module MyProject.cs
單次指令若產生多輸出檔,僅第一個檔案包含組件資訊清單。