Question

I download bootstrapper.exe from http://bootstrap.codeplex.com/, I manage to get it work in local IIS. At Application_Start() and use Process.Start()

But at Windows Azure, not work at all. I am sure file is there and no error message.

but no file download and unzipped. I tried both "local resource" folder or local folder

Does anyone here have a working code?

Était-ce utile?

La solution

First of all you need to have the bootstrapper.exe as part of your project (Add -> Existing Item -> browse to the bootstrapper.exe & .config include both of them). For the properties of these files, you must set "Build Action" to "None" and "Copy to output directory" to "Copy always".

Now you can use following code to run the bootstrapper (I do it like that and it works):

      internal void SomethingWithBootStrapper()
    {
        //
        Trace.TraceInformation("Trying to install agent...");
        ProcessStartInfo psi = new ProcessStartInfo();
        psi.FileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bootstrapper.exe");
        psi.Arguments = @"-get http://some_url_to_download_something.com/path/to/file.zip -lr $lr(YourLocalResourceKeyHere) -unzip $lr(YourLocalResourceKeyHere)\extract -run $lr(YourLocalResourceKeyHere)\extract\Setup.exe  -args /some /args /for_the_setup.exe -block";
        Trace.WriteLine("Calling " + psi.FileName + " " + psi.Arguments + " ...");
        psi.CreateNoWindow = true;
        psi.ErrorDialog = false;
        psi.UseShellExecute = false;
        psi.WindowStyle = ProcessWindowStyle.Hidden;
        psi.RedirectStandardOutput = true;
        psi.RedirectStandardInput = false;
        psi.RedirectStandardError = true;
        // run elevated
        psi.Verb = "runas";
        try
        {
            // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
            using (Process exeProcess = Process.Start(psi))
            {
                exeProcess.PriorityClass = ProcessPriorityClass.High;
                string outString = string.Empty;
                // use ansynchronous reading for at least one of the streams
                // to avoid deadlock
                exeProcess.OutputDataReceived += (s, e) =>
                {
                    outString += e.Data;
                };
                exeProcess.BeginOutputReadLine();
                // now read the StandardError stream to the end
                // this will cause our main thread to wait for the
                // stream to close (which is when ffmpeg quits)
                string errString = exeProcess.StandardError.ReadToEnd();
                Trace.WriteLine(outString);
                Trace.TraceError(errString);
                this._isInitialized = true;
            }
        }
        catch (Exception e)
        {
            Trace.TraceError(e.Message);
            this._isInitialized = false;
        }
    }

Please note, that this is 100% tested and working code!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top