Good day. There is a file written in C #, for example 'app.cs'. You need to compile this file through an application in C #. If the compiler produces a compile error, then you must redirect the output to a text file. The problem is that from C # a PowerShell script is executed in which the compiler itself is launched. I do not quite understand PowerShell, so I appeal to the community. The following is the code:
- PowerShell Script Code
@ "Start-Process -FilePath 'C: \ Program Files \ MSBuild \ 12.0 \ Bin \ csc.exe' -ArgumentList 'app.cs' -Wait -NoNewWindow | Out-File -FilePath log.txt"
C # code
string script = ... // см. выше Runspace runspace = RunspaceFactory.CreateRunspace(); runspace.Open(); Pipeline pipeline = runspace.CreatePipeline(); pipeline.Commands.AddScript(script); Collection<PSObject> result = pipeline.Invoke(); runspace.Close();
ps The result variable is also empty.