Reputation: 155
In Visual Studio my project builds without any problem, but from command line I get the error "Hard error". Project .net (c#)
Command line:
psinfo = new ProcessStartInfo(DEVENVPATH, @"""c:\Projects\[--pathtoproject--].sln"" /build");
psinfo.WindowStyle = ProcessWindowStyle.Hidden;
psinfo.UseShellExecute = false;
Process.Start(psinfo).WaitForExit();
I got error "Hard error" and Visual Studio crashed.
Upvotes: 9
Views: 12033
Reputation: 5930
You should use the MSBuild.exe or csc.exe instead of devenv.exe.
const string COMPILER = "PATH/TO/DEV/TOOLS/msbuild.exe";
// later in code
psinfo = new ProcessStartInfo(COMPILER, "PATH\TO\PROJECT\PROJECT_NAME.sln /t:Rebuild /p:Configuration=Release");
Compiling with devenv requires more parameters ( and i think it requires to add some informations about projects ):
psinfo = new ProcessStartInfo(DEVENVPATH, @"""c:\Projects\[--pathtoproject--].sln"" /build RELEASE");
Upvotes: 8