Rather than using start
to launch the program, consider cmd
. If you use cmd /K
it should stay open after the command runs, giving you time to inspect the output.
Run CSC.exe from command line using Batch File
Question
I am using the following batch script code to compile c# code but what I see is a black window (csc.exe) flashes and I can not see the exe file created.
start /wait C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe /out:aa.exe Program.cs
start aa.exe
pause
I want to create the file aa.exe at the same location as Program.cs
Basically what I want is to dynamically compile the code in Program.exe and run it. I am
using this following references:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Net.Mail;
Solution 2
OTHER TIPS
Don't forget to add the references in the command:
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\<dotnet_version>\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\<dotnet_version>\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\<dotnet_version>\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\<dotnet_version>\System.dll"
Use:
csc.exe /out:StackBackTraceOrRT_FATAL.exe StackBackTraceOrRT_FATAL.cs
Or you want use `CSharpCodeProvider?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow