Forum Discussion

levyas's avatar
levyas
Brass Contributor
May 20, 2021

MSIX: How to achieve automatic install of .net 5 required for my application?

Hi! 

I wrote a WPF program using .NET 5, packed it into the MSIX bundle (Release, x86 and x64) as a framework-dependent package. Everything seems fine, but there is one very annoying thing: on the first run the app says ".NET runtime is missing, would you like to install it?”. If you click yes, the download page opens, where the user has to select the needed runtime, download, and install it. Not the best user experience, I'm thinking about how to improve it.

Is there an option to add .net 5 runtimes (x86 or x64 depending on the user system, or maybe both) as a dependency so it installed automatically?

I know I can define dependencies, but how can I find the right name for the needed dependency?

Also, I know it's possible to define custom install action but I haven't tried it yet, because I want to find a simpler solution. Looks like for that option I'll have to create a small app or script that will check if the needed runtime exists and if not - check the platform and ask the user to install the specific version of the runtime. Not the best user experience too.

Of course, I still have an option to go with self-contained, but I don't want to distribute so many megabytes of .net every time, especially given the fact that I expect frequent updates.

 
 
  • Matteo Pagani's avatar
    Matteo Pagani
    May 24, 2021
    Hello, if it's an application based on .NET Core / .NET 5 (as I seem to understand from the description), the suggested and best way to distribuite via MSIX is to use the self-deployment approach. Thanks to MSIX features like differential updates and single disk instance, you don't have to worry too much about the increased size, since the runtime will be downloaded only at the first install.
    Otherwise, if you don't like self-deployment, you will need to use a script to pre-install the runtime. You can leverage some of the available script we release for CI/CD purposes here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

    I hope it helps!
  • levyas I haven't replied as I don't know the package name you'd need.  But ultimately, the AppXManifest file should have it listed as a Dependency package.  By listing it in as a dependency there, the system will install the dependency for you from the Windows Store.

     

    The form will be something like this example for the .Net.Native framefwork: "Microsoft.Net.Native.Framework.2.2.2.2.29512.0_x64__8wekyb3dbabbwe"

     

    I would guess you might need both framework and runtime referenced.  I'm not using any .NET 5 yet, so I'm not sure.  Possibly you can run the PowerShell command

                  get-appxpackage -PackageTypeFilter Framework

    On a system where the sdks are installed and they might show up.  You'd want value from the PackageFullName in your appxmanifest dependencies.

     

    If you find the answer, please post back and share!

     

    • levyas's avatar
      levyas
      Brass Contributor
      Thank you for the reply! You gave me the way to browse the catalog of available dependencies; that's very helpful! I read about the command, run on my machine, looks like it contains only frameworks used by UWP hence there are no familiar to me names or versions (like .net 4.7, or .net core or .net 5). At least now I know that it is not what I'm looking for, so thank you again.
      Maybe someday regular .net runtimes will be there too, that'd be nice.
  • levyas's avatar
    levyas
    Brass Contributor
    Tim Mangan, TIMOTHY_MANGAN, John Vintzel, Bogdan Mitrache - UR all great pros, if somebody could just point me in the right direction, I would be very glad. Thank you.
    It looks like quite an ordinary task, but I read all the docs and dozens of posts on the internet and didn't find a good solution for it, I think I'm losing something obvious.
    As I understood, with dependencies I can point to shared "framework" packages only, but I don't have one. With install actions or with PSF I will need to bundle the Dotnet installer with me, or download it from the MS site and run it with /quiet (because install-dotnet.ps1 intended only for CI machines), all of that looks far from an optimal solution. The best solution from bad ones I see is to use self-contained publish, but it's not the best too.
    • Matteo Pagani's avatar
      Matteo Pagani
      Icon for Microsoft rankMicrosoft
      Hello, if it's an application based on .NET Core / .NET 5 (as I seem to understand from the description), the suggested and best way to distribuite via MSIX is to use the self-deployment approach. Thanks to MSIX features like differential updates and single disk instance, you don't have to worry too much about the increased size, since the runtime will be downloaded only at the first install.
      Otherwise, if you don't like self-deployment, you will need to use a script to pre-install the runtime. You can leverage some of the available script we release for CI/CD purposes here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

      I hope it helps!
      • levyas's avatar
        levyas
        Brass Contributor
        Thank you! I thought about using the install-dotnet.ps1, but looks like it's much more complicated than to just use a self-contained package.
        Also, I'm "scared" a little of "To set up a development environment or to run apps, use the installers rather than these scripts." and the fact that there will be no registry entries or persistent PATH to dotnet.
        So, I'll take a less risky and simpler approach by making the app self-contained.
        Thank you again, Matteo.

Resources