我想以编程方式运行visual studio命令。我尝试了上述代码,但没有任何帮助。我得到的是打开了我的项目目录的命令提示符。无法打开Visual Studio命令提示符实用地使用VS 2015
我已经使用Execute(“VS140COMNTOOLS”)作为输入。
private void Execute(string vsEnvVar) {
var vsInstallPath = Environment.GetEnvironmentVariable(vsEnvVar);
if (Directory.Exists(vsInstallPath)) {
var filePath = vsInstallPath + "vsvars32.bat";
if (File.Exists(filePath)) {
//start vs command process
Process proc = new Process();
var command = Environment.GetEnvironmentVariable("ComSpec");
command = @"" + command + @"";
//var batfile = @"E:\Test\vstest.bat";
var args = string.Format("/S/K \" \"{0}\" \"", filePath);
proc.StartInfo.FileName = command;
proc.StartInfo.Arguments = args;
//proc.StartInfo.RedirectStandardInput = true;
//proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.UseShellExecute = false;
proc.Start();
} else {
Console.WriteLine("File Does not exists " + filePath);
}
}
}
现在,你可以执行任何命令,为什么2手轮报价与他们之间的空间的批处理文件? – BugFinder