Search code examples
c#.netdeploymentmauimime-types

How to configure the MIME types for .net web app for using msix app package to install maui


I'm trying to deploy my MAUI web application on IIS web server. The only guide I found is this : https://learn.microsoft.com/en-us/windows/msix/app-installer/web-install-iis

Unfortunately in this article used .net framework 4.7 which is not acceptable for me. I'm trying to reproduce similar behaviour on my .NET 6 web app.

This is my maui installation page :

@page
@model IndexModel
@{
    ViewData["Title"] = "Home page";
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Install<a href="ms-appinstaller:?source=https://localhost:7123/packages/Test.msix">MAUI</a>.</p>
</div>

But I'm getting this error message in msix package insulator "Error in parsing the app package.".

I'm assuming that the problem is with missed configured MIME type since I can't open the file manually from browser, but I do not understand how to configure mime types on .net 6 web app.

Guided by this article:

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0&viewFallbackFrom=aspnetcore-2.1&tabs=aspnetcore2x#fileextensioncontenttypeprovider

I configured my static file like this :

var provider = new FileExtensionContentTypeProvider();
// Add new mappings
provider.Mappings[".msix"] = "application/msix";
provider.Mappings["msix"] = "application/msix";

app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = new PhysicalFileProvider(Directory.GetCurrentDirectory()),
    RequestPath = "/home/packages/Test.msix",
    ContentTypeProvider = provider
});


var fileProvider = new PhysicalFileProvider(Directory.GetCurrentDirectory());
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
    FileProvider = fileProvider,
    RequestPath = "/home"
});

But It still doesn't work, and I do not understand why.

I uploaded test project on GitHub : https://github.com/IgorMarkiv/mauiDeployTest


Solution

  • It's look like ms-installer protocol was disabled by Microsoft. I'm referring to Microsoft documentation : https://learn.microsoft.com/en-us/windows/msix/app-installer/installing-windows10-apps-web

    So now I'm just downloading a regular file and opening manually. At least until they will fix security issues.