Create a project in 2017 Visual Studio from the command line?

In Visual Studio, my project is created without any problems, but from the command line I get a "Hard Error" error message. .Net project (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 a "Hard Error" error and crash in Visual Studio.

+5
source share
1 answer

You should use 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 options (and , I think, some project information needs to be added):

 psinfo = new ProcessStartInfo(DEVENVPATH, @"""c:\Projects\[--pathtoproject--].sln"" /build RELEASE"); 
+6
source

Source: https://habr.com/ru/post/1260864/


All Articles