SOLVED

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

Brass Contributor

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.

 
 
18 Replies
@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.

@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!

 

best response confirmed by levyas (Brass Contributor)
Solution
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!
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.
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.
Hi Matheo, can you please provide some explanations to your suggestion "to use a script to pre-install the runtime"? Can this script be added to the MSIX package and referenced in the manifest? If yes, how?
Custom install action mentioned by levyas does seem to be applicable since "it is intended to be used only by desktop PC games that are packaged in an MSIXVC container" as stated in desktop6:InstallActions. If instead of running scripts, it would be possible to add the .NET 5 and ASP..Net references as Dependency packages to the AppXManifest file, could you provide an example of such an extension deploying .NET 5 and ASP.,Net?
Hi Matteo,
Two weeks ago I asked you to explain how to add .NET 5 and ASP..Net references as Dependency packages to the AppXManifest file or to to pre-install the runtime using a script Thanks in advance for your suggestions and recommendations.

@Valery Atlas I apologize, I missed the notification about your question. In a .NET 5 scenario, the best to achieve what you're trying to do is to use the self-contained deployment model (https://docs.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained), where the full runtime and all its dependencies will be included inside the package.

Scripts can be executed at the first launch using the Package Support Framework (https://docs.microsoft.com/en-us/windows/msix/psf/run-scripts-with-package-support-framework), but they still run inside the container, so it's not a good way to install dependencies which must be system-wide.

 

I hope it helps!

Hi Matteo,
Thanks for your considerations.
The self-contained deployment model seems to have significant security related issues and may require regular patches from ISVs. This is what Microsoft Tech Support experts mentioned in their reply to my inquiry about deploying ..NET and Asp.NET components. They said that the global distribution of these prerequisites is the most reliable option that has a number of advantages, If you wish, I can share with you our email exchange.
This is why I would like to concretize how to deploy the redistributable packages, such as .NET, Asp..NET or .NET SDK. Running a script using PSF seems to be quite problematic because deployment of these prerequisites will require elevation. Is it possible to add the .NET 5 and ASP..Net references as Dependency packages to the AppXManifest file?
Thanks for your suggestions!
No, unfortunately that's not possible. The Dependencies section of the manifest supports only a very specific subset of packages created by the Windows team, like VC++ libraries or the Project Reunion framework. .NET and ASP.NET aren't supported dependencies. I'm afraid that, if you want to go with MSIX, your best option is to use self-contained. I don't fully agree that the self-contained model has significant security issues but, for sure, it requires the ISV to own the patching and updating of the runtime (which might make things complicated in big enteprise environment, where a new version of the app must be deployed to all the devices in the company).
Well, this seems to be a significant limitation. Why are VC++ libraries or the Project Reunion framework supported for such a distribution, whereas .NET prerequisites cannot be added to this "very specific subset of packages"?
As you mentioned, a self-containing deployment model does make things complicated in a big enterprise environment, this is why it would be very advantageous to provide the support for distribution of .NET prerequisites using the Dependencies section of the manifest. Why .NET prerequisites have a different status compared with VC++ runtime and what are the main obstacles for adding the to the subset of the supported packages?
As long as this support is not provided, how to use the script related alternative mentioned in your message? Script will require elevation, and this will mean that the ;main app in the MSIX package will be launched prior to completing the script execution. Can you please shed some light on this alternate option or, perhaps, provide a simple example?
Yours is a good question, but I don't really have an answer unfortunately. .NET uses different distribution channels for their runtimes, and they aren't currently distributed as MSIX, therefore they aren't available as dependencies.
As I mentioned in the other comment, the scripting option wouldn't be a good fit here. Since the script is executed inside the same container of the MSIX packaged app, this feature isn't a good fit for dependencies which must be installed system wide (like the .NET runtime) and with administrative rights.
Unfortunately, out of the box, I can't think of an easy solution for your scenario other than using self-contained deployment. Sorry!
Thanks for your considerations, Matteo. As you can see, this seems to be a common deployment scenario, and in many cases a system-wide deployment of .NET prerequisites may be the only plausible option. BTW, the popular MsixHero tool also utilizes the .NET system-wide deployment model instead of rather problematic self-contained option, and adding support for .NET distribution would significantly simplify its deployment. I would appreciate if you could submit to the MSIX team the request to add at least .NET and Asp.NET packages to the subset of supported libraries, this would be indeed very helpful. Thank you very much in advance!
To state the obvious, if Microsoft wants to encourage developers to move to these technologies, there must be a better way to handle the dependencies outside of those suggested here. The same reasons for wanting the components outlined by Matteo that are supported as package dependencies apply to .Net 5, and Microsoft should add a solution. The package dependency route seems the most obvious to me, but I'm guessing there are technical reasons this hasn't been (yet).
Thanks for the feedback Timothy and Valery. I'll make sure to convey it to the MSIX team, to see if they can start a conversation with the .NET team on this topic.
Many thanks, Matteo, much appreciated!
I think the requested extension will be very beneficial for ISVs.
BTW, I have a question about your recommendations in Chapter 4 of your MSIX Succinctly book (https://www.syncfusion.com/succinctly-free-ebooks/msix-succinctly/the-package-support-framework) Would it be possible to clarify with you some issues in this regard?
Sure, feel free to send me a mail at name.surname [at] microsoft.com
1 best response

Accepted Solutions
best response confirmed by levyas (Brass Contributor)
Solution
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!

View solution in original post