To have the .NET Desktop Runtime installed automatically with a WinForms app deployed via a Visual Studio installer (MSI/Setup.exe), configure prerequisites in the setup/installer project so the bootstrapper handles the runtime before your app installs.
For Visual Studio Installer Projects (vdproj) targeting .NET (WinForms/WPF):
- Open the solution that contains both the WinForms project and the Setup project.
- In Solution Explorer, select the Setup project (the .vdproj).
- Open the Properties window for the Setup project.
- Select the Prerequisites… button.
- In the Prerequisites dialog:
- For a WinForms app, select .NET Desktop Runtime… (this is the appropriate prerequisite for WPF/WinForms apps; .NET Core Runtime… is for console apps).
- Choose how the prerequisite is obtained:
- From the vendor’s site, or
- From the same location as the application (if the redistributable is packaged alongside your installer).
- Build the Setup project.
The resulting bootstrapper (Setup.exe) will then:
- Check for the required .NET Desktop Runtime on the target machine.
- Download or install it (depending on the option chosen) before installing the WinForms application.
If more complex installation logic is required (for example, multiple chained prerequisites or custom logic), consider:
- Using the WiX Toolset Visual Studio Extension to build MSI-based installers with explicit .NET prerequisites.
- Using InstallShield integrated with Visual Studio to define .NET Framework/runtime dependencies.
These options allow building MSI/EXE installers that ensure the .NET runtime is present before the application is installed.
References: