Wix Bootstrapper - 从安全的 http 存储库下载捆绑包

Posted

技术标签:

【中文标题】Wix Bootstrapper - 从安全的 http 存储库下载捆绑包【英文标题】:Wix Bootstrapper - download bundle packages from a secured http repository 【发布时间】:2013-12-13 13:49:44 【问题描述】:

我正在开发一个烧录引导程序,它需要从需要身份验证的 http 存储库下载先决条件。 那么,我应该如何处理这个请求呢?

谢谢!

【问题讨论】:

您想提示用户输入适当的凭据,还是正在寻找一种(安全地)嵌入凭据的方法? (第二个是不可能的,但最好知道你要走哪条路) 不,不会提示用户输入凭据;我正在寻找指定凭据的方法。方法 Engine.SetDownloadSource() 已经支持,但我不知道如何使用它。参考:***.com/questions/13346168/… 【参考方案1】:

知道了!这可以在 OnResolveSource() 事件上实现:

// variable used for authentication
static const LPCWSTR WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_USER = L"HTTPDownloadUserName";
static const LPCWSTR WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_PASS = L"HTTPDownloadPassword";

virtual STDMETHODIMP_(int) OnResolveSource(
    __in_z LPCWSTR wzPackageOrContainerId,
    __in_z_opt LPCWSTR wzPayloadId,
    __in_z LPCWSTR wzLocalSource,
    __in_z_opt LPCWSTR wzDownloadSource
    )

    int nResult = IDERROR; // assume we won't resolve source and that is unexpected.

    LPWSTR sczHTTPDwnUserName = NULL;
    LPWSTR sczHTTPDwnPassword = NULL;
    BOOL bUseHTTPAuth = FALSE;

    if (BalStringVariableExists(WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_USER))
    
        HRESULT hrUsr = BalGetStringVariable(WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_USER, &sczHTTPDwnUserName);
        HRESULT hrPwd = BalGetStringVariable(WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_PASS, &sczHTTPDwnPassword);
        if (SUCCEEDED(hrUsr) && SUCCEEDED(hrPwd)) bUseHTTPAuth = TRUE;
    

    if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display)
    
        if (wzDownloadSource)
        
            if (bUseHTTPAuth)
            
                HRESULT hr = m_pEngine->SetDownloadSource(wzPackageOrContainerId, wzPayloadId, wzDownloadSource, sczHTTPDwnUserName, sczHTTPDwnPassword);
                nResult = SUCCEEDED(hr) ? IDDOWNLOAD : IDERROR;
             
            else
                nResult = IDDOWNLOAD;
        
        else // prompt to change the source location.
        
            // related stuff
        
    
    else if (wzDownloadSource)
    
        // If doing a non-interactive install and download source is available, let's try downloading the package silently
        if (bUseHTTPAuth)
        
            HRESULT hr = m_pEngine->SetDownloadSource(wzPackageOrContainerId, wzPayloadId, wzDownloadSource, sczHTTPDwnUserName, sczHTTPDwnPassword);
            nResult = SUCCEEDED(hr) ? IDRETRY : IDERROR;
         
        else
            nResult = IDDOWNLOAD;
    
    // else there's nothing more we can do in non-interactive mode

    return CheckCanceled() ? IDCANCEL : nResult;

【讨论】:

你到底在做什么?究竟是如何利用 OnResolveSource 的?

以上是关于Wix Bootstrapper - 从安全的 http 存储库下载捆绑包的主要内容,如果未能解决你的问题,请参考以下文章

从 Wix Bootstrapper Bundle 检查文件版本

将参数从bootstrapper传递到msi bundle包

WiX-Bootstrapper - 为 UAC 对话框设置产品名称和公司名称

WiX Bootstrapper 项目结构

自定义 Bootstrapper UI,类似于自定义的 wix UI

WiX Burn Bootstrapper 不调用 OnDetectRelatedBundle