1

I am very new to C# and am wanting to write my code using a text editor like Notepad++ and compile using csscript. I have the two working and I am getting results from my code.

However, so far, I have only been able to run my code as interpreted, but I will eventually want to compile exe or dll files.

Am I able to compile my code into a standalone exe or dll using notepad++ and csscript, please?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
hemis
  • 45
  • 1
  • 2
  • 11
  • 4
    Why are you making your life harder especially when “very new to C#”? Download an install Visual Studio. The Express edition is free. – Ondrej Tucny Dec 27 '13 at 21:58
  • 1
    Not sure what CSScript you are talking about... but if you are interested in REPL check out this question - http://stackoverflow.com/questions/10980596/c-sharp-interactive-repl-outside-visual-studio-roslyn ... (I completely agree that VS Express is likely much more convenient to start with C# - integrated help, broad community to get answers from on IDE itself)... You may also try LINQPad... – Alexei Levenkov Dec 27 '13 at 22:04

6 Answers6

1

Just an update for your original question...

CS-Script plugin for Notepad++ actually allows building normal executables that can be executed as any other managed exe.

user3032112
  • 141
  • 3
1

Little too late, but here's the one that worked for me: I called this batch script bnr.bat (Build and Run)

echo Building project..
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /out:"%1\%2.exe" %3
echo Running project
%1\%2.exe
pause

Save this bnr.bat file and and then use NPP's Run and set The Program to Run as follows and before you press Run button, press Save and provide your custom shortcut keys:

<directory_where_you_saved_bnr.bat>\bnr.bat $(CURRENT_DIRECTORY) $(NAME_PART) $(FULL_CURRENT_PATH)

the $ constants are defined internally in NPP:

$(CURRENT_DIRECTORY) is the full path of the directory containing your C# file.

$(NAME_PART) is the name of your C# file minus extension (.cs).

$(FULL_CURRENT_PATH) is the full path for your C# file.

This does not have any error checking, but pause in batch script will allow you to see the errors and exceptions within the console before you exit the script.

I had set the PATH environment variabile, but somehow this batch script did not find csc.exe, because it was looking at the npp bin directory.

Vikrant
  • 253
  • 4
  • 15
1

For .NET 5+ (and .NET Core), you can compile your project using the .NET Command Line Interface (CLI)

The command

dotnet publish

creates the files you need to run your program.

Eric J.
  • 147,927
  • 63
  • 340
  • 553
0

No, you will need a compiler (Microsoft´s from VS or Mono)

deviantfan
  • 11,268
  • 3
  • 32
  • 49
0

csc.exe is what you need. It should be at C:\Windows\Microsoft.NET\Framework\v4.0.30319.

Here is a link to a reference. http://msdn.microsoft.com/en-us/library/2fdbz5xd.aspx

And check out Visual Studio express, it makes life easier.

quarksoup
  • 129
  • 6
0

Thanks for the reply.

I have Visual studio but the license expires in 7-days.

I am using Notepad++ with an add-in called cs-script. The add-in checks and runs code in a similar manner to Visual studio but it will not compile an exe or dll file.

However, to answer my own question and as suggested by quarksoup, the answer lies within the csc comiler. By using the /flags, I am able to compile my programs from the command-line. I shall write a batch file that will do the work for me.

Regards

hemis
  • 45
  • 1
  • 2
  • 11