How to compile just one file in c#?

前端 未结 7 1183
星月不相逢
星月不相逢 2020-12-28 15:54

In VC++ I can press CTRL+F7 to compile a single file, or right click on a source file ot compile it. Is it possible to compile a single file (or current file) in C#?

7条回答
  •  一生所求
    2020-12-28 16:39

    For single .cs file compile + run:

    1. In VS 2008, go to "Tools" > "External Tools"
    2. Click on "Add"
    3. Title: Run CSC (or whatever you want)
    4. Command: C:\Windows\system32\cmd.exe
    5. Arguments: /c C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe /target:winexe $(ItemPath) && $(ItemFileName)
    6. Initial directory: $(ItemDir)
    7. Check Use Output Window
    8. Apply + Ok
    9. Go to Tools and choose "Run CSC"

    If this doesn't work, verify that your paths for cmd and csc match.

提交回复
热议问题