简体   繁体   English

使用NPPExec脚本在Notepad ++中使用csc.exe编译C#

[英]Compiling C# with csc.exe from within Notepad++ using NPPExec script

I'm having trouble writing a NPPExec script (for Notepad++) to compile C# source using Microsoft's csc.exe. 我在编写NPPExec脚本(用于Notepad ++)时无法使用Microsoft的csc.exe编译C#源代码。 I had no problem getting MinGW up and running for my c++ stuff, but the same script structure doesn't seem to work for C#. 我没有问题让MinGW启动并运行我的c ++东西,但是相同的脚本结构似乎对C#不起作用。 Does anybody have a working C# NPPExec script? 有没有人有一个有效的C#NPPExec脚本?

Three quick notes: 三个快速笔记:

  1. While my mingw installed to a path with no spaces (\\MinGW\\bin), it appears that my C# compiler is buried in \\Program Files\\, a path with multiple spaces. 虽然我的mingw安装到没有空格的路径(\\ MinGW \\ bin),但我的C#编译器似乎埋没在\\ Program Files \\中,这是一个包含多个空格的路径。 Does this matter? 这有关系吗?

  2. I was able to compile using the Microsoft SDK-installed command prompt (which I think sets some environment variables), so I know the compiler works. 我能够使用Microsoft SDK安装的命令提示符(我认为设置一些环境变量)编译,所以我知道编译器工作。

  3. In the NPPExec option box, I have selected FOLLOW $(CURRENT_DIRECTORY). 在NPPExec选项框中,我选择了FOLLOW $(CURRENT_DIRECTORY)。 Does this matter? 这有关系吗?

Thanks. 谢谢。

Here is my nppexec script for C# (.NET 3.5) to compile the currently opened file and run: 这是我用于C#(.NET 3.5)的nppexec脚本,用于编译当前打开的文件并运行:

"c:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe" /out:"$(FULL_CURRENT_PATH).exe" "$(FULL_CURRENT_PATH)"
"$(FULL_CURRENT_PATH).exe"

In the "Plugins -> NppExec" menu: 在“插件 - > NppExec”菜单中:

Select "Save all files on execute"
Select "Follow $(CURRENT_DIRECTORY)".

Answers for your questions: 您的问题的答案:
1) Use double quotes (") for full path of csc like my configuration. 1)使用双引号(“)作为csc的完整路径,就像我的配置一样。
2) At least for .NET 3.5, only full path to csc is enough, no need to load VS environment variables. 2)至少对于.NET 3.5,只有csc的完整路径就足够了,不需要加载VS环境变量。
3) It is better to select "FOLLOW $(CURRENT_DIRECTORY)" so that the compiled EXE is under the same directory. 3)最好选择“FOLLOW $(CURRENT_DIRECTORY)”,以便编译的EXE位于同一目录下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM