I want to execute ng build using c# code to build my angular project. I have hosted by c# application on IIS. When I am executing code I am getting error:
ng' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n
I have created another application that I have not hosted on IIS and I am executing that with locally using visual studio. In that same code is working property. I am unable to figure out issue with iis. My code is as below.
private void buildAngular()
{
try
{
Process p = new Process();
p.EnableRaisingEvents = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.WorkingDirectory = @"D:\AngularToBuild\AngularProject";
p.StartInfo.UseShellExecute = false;
//p.StartInfo.Arguments = @"/c echo off > fff1.txt";
p.StartInfo.Arguments = @"/c ng build";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start();
p.Exited += new EventHandler(myProcess_Exited);
var err = p.StandardError.ReadToEnd();
var msg = p.StandardOutput.ReadToEnd();
Console.WriteLine("error", msg, err);
}
catch (Exception ex)
{
Console.WriteLine("error");
}
}
private void myProcess_Exited(object sender, System.EventArgs e)
{
Console.WriteLine("Exit time: {0}\r\n" +
"Exit code: {1}\r\nElapsed time: {2}");
}