Publish ASP.Net Code with cmd Line using Process
Hello Friends,
All of us know how to publish a website in VS2005 (It is fairly simple).
I am publishing a ASP.NET application using VS2005 Command prompt and i succeed in it also.
Here is what i wrote on VS2005 Command prompt
aspnet_compiler -v /ABC -p E:\ABC -f -fixednames "D:\Publish" -c
The above code will publish the website ABC which is a virtual directory
in IIS with physical location E:\ABC. The target directory is
D:\Publish where we get the Resultant published code.
The same i willing to do using a Button_Click event
Here is the code.
Button_Click event
{
System.Diagnostics.Process p1 = new Process();
p1.StartInfo.ErrorDialog = true;
p1.StartInfo.UseShellExecute = false;
p1.StartInfo.RedirectStandardOutput = true;
p1.StartInfo.RedirectStandardError = true;
p1.StartInfo.FileName = @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\as pnet_compiler.exe";
p1.StartInfo.Arguments = "aspnet_compiler
-v /ABC -p E:\ABC -f -fixednames \""D:\Publish"\" -c";
p1.Start();
string s = p1.StandardOutput.ReadToEnd();
MessageBox.Show(s);
}
I donot think there is any thing wrong in concatenating the argument string.
Still I get an Error Message and Website is not published
ERROR 1001 : Unexpected parameter :'D:\Publish'.
NOTE:
When u debug this code and copy the value of the expression p1.StartInfo.Arguments and paste in VS2005 Command prompt the code compiles without any error and Website gets published on the Target directory.
Then what is Missing in the Code.
All opinions will we accepted. Thanks in advance.
|