0

bootstrapper.exeをhttp://bootstrap.codeplex.com/からダウンロードし、ローカルIISで動作させることができます。Application_Start()で、Process.Start()を使用します

しかし、Windows Azureでは、まったく機能しません。ファイルがあり、エラーメッセージはないと確信しています。

ただし、ファイルのダウンロードと解凍は行われません。「ローカルリソース」フォルダまたはローカルフォルダの両方を試しました

ここの誰かが動作するコードを持っていますか?

4

1 に答える 1

1

まず、プロジェクトの一部として bootstrapper.exe を用意する必要があります (追加 -> 既存のアイテム -> bootstrapper.exe & .config を参照して両方を含めます)。これらのファイルのプロパティについては、[ビルド アクション] を [なし] に、[出力ディレクトリにコピー] を [常にコピー] に設定する必要があります。

これで、次のコードを使用してブートストラッパーを実行できます (私はそのようにして動作します)。

      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;
        }
    }

これは 100% テスト済みで動作するコードであることに注意してください。

于 2011-11-11T09:06:55.687 に答える