0

I recently upgraded my WPF app from .NET framework 4.7 to .NET 6. But when I try to deploy my app on my client's computer, my app won't start because this new computer don't have .NET Desktop Runtime installed. So, how do I detect the absence of .NET runtime and promt a window asking the app user to download .NET runtime? Just like the below picture: ask user to install .NET runtime

I'm not using any installer, just copy and paste my build folder to the new machine.

I remember that when I was using .NET framework, if the runtime was missing, the Windows system would automatically promt a window ask me to download the runtime.

Lance U. Matthews
  • 15,725
  • 6
  • 48
  • 68
Nowayout
  • 127
  • 9
  • 2
    It is clear that, you can't do this from your application code itself. So you need some external code which is not dependent on .NET 6 to check the presence of .NET 6. You can't call that code from your application start up because your application won't event start without .NET 6. So you need some custom installer which will check for prerequisites before copying the files to the target computer, display message and halt the installation. – Chetan Jun 13 '22 at 01:56
  • 2
    Or alternatively just use self-contained https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained – Martheen Jun 13 '22 at 01:57

1 Answers1

2

Obviously your .NET 6 app won't be able to start and even less detect something unless the .NET 6 runtime is installed on the machine where you run the app.

To overcome this issue, you could bundle the .NET 6 runtime with your app by publishing it as self-contained:

dotnet publish -r win-x86

You will then copy the entire output of the publish folder, which includes the necessary .NET assemmblies, to the target machine.

Please refer to the linked docs for more information.

mm8
  • 163,881
  • 10
  • 57
  • 88