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

发布于 2024-12-14 12:32:38 字数 289 浏览 1 评论 0原文

我从 http://bootstrap.codeplex.com/ 下载 bootstrapper.exe,我设法让它工作本地 IIS。 在 Application_Start() 并使用 Process.Start()

但在 Windows Azure 上,根本不起作用。 我确定文件在那里并且没有错误消息。

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

这里有人有工作代码吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独自←快乐 2024-12-21 12:32:38

首先,您需要将 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% 经过测试且有效的代码!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文