Asp.net 如何让BootStrapper.exe在Windows Azure中工作?

Asp.net 如何让BootStrapper.exe在Windows Azure中工作?,asp.net,azure,bootstrapper,application-start,Asp.net,Azure,Bootstrapper,Application Start,我从下载bootstrapper.exe,我设法让它在本地IIS中工作。 在应用程序_Start()中,使用Process.Start() 但在WindowsAzure上,根本不起作用。 我确信文件在那个里,并没有错误消息 但没有文件下载和解压缩。我尝试了“本地资源”文件夹或本地文件夹 这里有人有工作代码吗?首先,您需要将bootstrapper.exe作为项目的一部分(添加->现有项->浏览到bootstrapper.exe和.config,包括这两个)。对于这些文件的属性,必须将“生成操作”

我从下载bootstrapper.exe,我设法让它在本地IIS中工作。 在应用程序_Start()中,使用Process.Start()

但在WindowsAzure上,根本不起作用。 我确信文件在那个里,并没有错误消息

但没有文件下载和解压缩。我尝试了“本地资源”文件夹或本地文件夹


这里有人有工作代码吗?

首先,您需要将bootstrapper.exe作为项目的一部分(添加->现有项->浏览到bootstrapper.exe和.config,包括这两个)。对于这些文件的属性,必须将“生成操作”设置为“无”,将“复制到输出目录”设置为“始终复制”

现在,您可以使用以下代码来运行引导程序(我就是这样做的,它可以正常工作):


请注意,这是100%测试和工作的代码

谢谢,你的建议提醒我,我忘记了“BootStrapper.exe.config”文件。因为它在本地IIS中工作,所以我再也没有想过这个文件:(@astaykov-出于好奇,你为什么不把这个命令放在一个bat文件中,然后从启动任务中调用呢?这是我构建bootstrapper的最初用例。@dunnry,我不认识他,但对我来说,我不使用.bat文件是因为我需要在运行时获取一些参数。谢谢你构建的好工具。dunnry,我可以使用bootstrapper在一个复杂得多的场景中,然后只是一个启动任务;)当然我也在批处理文件中使用启动任务。Eric,在启动任务中可以得到很多参数,但我同意有些参数在运行时之前是不存在的:)理解。若你们能给我写封信,我也许能帮你们让bootstrapper更有价值。我的最终目标是,您不必通过进程调用它。Start()。:)
      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;
        }
    }