I'm trying to do a Drupal site install using Drush in C# as part of a full Windows Server site installation using MSI. The Drush commmand I am using is the following one.
C:\ProgramData\Drush\Drush.bat -y si application_name --db-url=sqlsrv://admin_name:password(local)\SQLEXPRESS:/database_name --account-name=admin --account-mail=name@test.com --account-pass=Password1234 --site-mail="admin@company.com" --site-name="Site Name" install_configure_form.site_default_country=GB install_configure_form.date_default_timezone="Europe/London"
And this works perfectly when run from cmd.exe when in the working directory (inetpub\application_name).
The issue arises when the above is put into code and executed during an installation and always results in the following error (with a different file name each time).
Unable to decompress C:\ProgramData\Drush\lib\druFD63.tmp.gz
The C# code being used to execute the command is as follows:
public static ActionResult Drush_Configuration(Session session)
{
string strArgs = "-y si application_name --db-url=sqlsrv://admin_name:password(local)\SQLEXPRESS:/database_name --account-name=admin --account-mail=name@test.com --account-pass=Password1234 --site-mail="admin@company.com" --site-name="Site Name" install_configure_form.site_default_country=GB install_configure_form.date_default_timezone="Europe/London";
string strExeCmd = @"C:\ProgramData\Drush\Drush.bat ";
strExeCmd = strExeCmd + strArgs;
string strLocation = @"C:\inetpub\application_name";
session.Log("Starting Drush Configuration");
session.Log("Command line is: " + strExeCmd + " " + strArgs);
int exitCode;
ProcessStartInfo processInfo;
Process process;
try
{
processInfo = new ProcessStartInfo("cmd.exe", "/c " + strExeCmd);
processInfo.WorkingDirectory = strLocation;
processInfo.WindowStyle = ProcessWindowStyle.Normal;
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
// *** Redirect the output ***
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
process.WaitForExit();
// *** Read the streams ***
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
exitCode = process.ExitCode;
session.Log("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
session.Log("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
session.Log("ExitCode: " + exitCode.ToString(), "ExecuteCommand");
process.Close();
}
catch (Exception e)
{
session.Log("Error: " + e);
return ActionResult.Failure;
}
session.Log("Drush Configuration completed successfully");
return ActionResult.Success;
}
And as stated above, this always results in the "unable to decompress" error.
Has anyone ever used c# to run Site-Install in Drush? Does anyone know why this might fail when executed in this way?
Any thoughts or advice would be greatly appreciated.
I am using Drush-5.8-2012-12-10-Installer-v1.0.20, Drupal 7, and Windows Server 2008 R2 x64.