I came with this workaround:
1. I create a .bat file.
2. I write the commands in it.
3. Finally I start the .bat file as a Process.
StreamWriter w = new StreamWriter(@"C:\temp\publish.bat");
w.WriteLine(@"call ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat""");
w.WriteLine(@"call cd ""C:\Users\Johan\Documents\Visual Studio 2008\Projects\CCOSApp""");
w.WriteLine(@"call msbuild /target:Build /p:BuildingProject=true;OutDir=C:\Temp\build");
w.WriteLine("call ccosapp.sln");
w.Close();
System.Diagnostics.Process proc = new System.Diagnostics.Process();
ProcessStartInfo psi = new ProcessStartInfo(@"publish.bat");
psi.WorkingDirectory = @"C:\temp\";
proc.StartInfo = psi;
proc.Start();