<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>
<%@ Import Namespace="System.Diagnostics" %>
<script runat="server">
protected override void OnInit(EventArgs e)
{
string filePath = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe";
string param = @" E:\Dev\CNBlogsJob.sln /p:Configuration=release";html
filePath = "notepad.exe";
param = "";ide
//以release方式編譯CNBlogsJob.sln
ProcessStartInfo info = new ProcessStartInfo(filePath, param);
//將控制檯輸出重定向至StandardOutput,若是爲false,就沒法獲得控制檯輸出結果
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Process p = Process.Start(info);
//下面一行代碼是爲了模擬控制檯的顯示效果
Response.Write("<body style=\"color:#DDD;background-color:#000;\">");
//控制檯輸出結果
Response.Write(p.StandardOutput.ReadToEnd().Replace("\n","<br/>"));
Response.Write("</body>");
p.WaitForExit();
p.Close();
}
</script>
<!DOCTYPE html>ui
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>spa