UWP 應用程式安裝透過 UI 失敗,可在 PowerShell 中執行

UWP 應用程式安裝透過 UI 失敗,可在 PowerShell 中執行

我正在嘗試分發 UWP 應用程序,但遇到了一個稍微奇怪的問題。

  • 該應用程式是使用自動更新功能從 Visual Studio 構建的,生成.appinstaller文件和關聯的 MSIX 捆綁包等
  • 這些工件被上傳到 Azure 應用服務進行分發
  • 下載並運行該.appinstaller文件會出現錯誤Error in parsing the app package.- 不是特別有幫助
  • 該應用程式使用安裝在下面的憑證進行簽名Trusted Publishers
  • 伺服器上的檔案web.config設定為正確映射 MIME 類型:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".appx" mimeType="application/appx" />
      <mimeMap fileExtension=".msix" mimeType="application/msix" />
      <mimeMap fileExtension=".appxbundle" mimeType="application/appxbundle" />
      <mimeMap fileExtension=".msixbundle" mimeType="application/msixbundle" />
      <mimeMap fileExtension=".appinstaller" mimeType="application/appinstaller" />
    </staticContent>
  </system.webServer>
</configuration>
  • 使用正確安裝的應用程式從 PowerShell(未提升)執行安裝Add-AppxPackage -Appinstaller https://[test].azurewebsites.net/[appname].appinstaller,然後運作正常。

  • 使用 Fiddler,我觀察到透過 UI 安裝會導致伺服器出現 412 錯誤:

要求:

GET https://[test].azurewebsites.net/[appname]_1.0.0.0_Test/[appname]_1.0.0.0_x64.msixbundle HTTP/1.1
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
If-Match: W/"086c9a4cfd51:0"
Range: bytes=10878976-11010047
If-Unmodified-Since: Mon, 20 May 2019 20:42:56 GMT
Host:[test].azurewebsites.net

回覆:

HTTP/1.1 412 Precondition Failed
Content-Length: 86
Content-Type: text/html
Last-Modified: Mon, 20 May 2019 20:42:56 GMT
Accept-Ranges: bytes
ETag: W/"086c9a4cfd51:0"
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Mon, 20 May 2019 20:21:12 GMT

The request was not completed due to preconditions that are set in the request header.
  • PowerShell 用戶端似乎沒有傳送If-Unmodified-SinceIf-Match標頭。
GET https://[test].azurewebsites.net/[appname]_1.0.0.0_Test/[appname]_1.0.0.0_x64.msixbundle HTTP/1.1
Connection: Keep-Alive
Range: bytes=11079260-11145819
User-Agent: App Virt Client/1.0
Host: [test].azurewebsites.net

鑑於上述情況:

  • .appinstaller我是否缺少在 IIS 下託管 UWP 的任何明顯的伺服器配置?
  • 透過 UI 旁加載 UWP 應用程式是否存在任何已知問題.appinstaller
  • 有沒有辦法將 IIS 配置為忽略先決條件,以測試這些先決條件是否會導致問題?

編輯:

找到一個日誌檔(AILog.txt):

[Tue May 21 15:40:17 2019]{10188} Manifest Info -> Package is Not Headless
[Tue May 21 15:40:17 2019]{10188} Manifest Info -> Package is Not a Modification Package
[Tue May 21 15:40:17 2019]{10188} ERROR: AppsInfo -> Error: [0x80004005]

編輯2:

經過大量調查後,我得到了一個工作版本,變化相對較少:

  • EnableDotNetNativeCompatibleProfile(我將其設置為true
  • RuntimeIdentifiers(我將這些添加到 .csproj 檔案中)
  • 從 VS2017 而不是 VS2019 構建

希望消除過程能夠確定其中哪一個是罪魁禍首。

相關內容