1
votes

I have a simple C# application which I need to create a silent installer for. I am using Visual Studio Installer (MSI-based). Since it is C# application, installer must install .NET framework as prerequisites.

Setup project in my solution produces 2 files: setup.exe, and app.msi, a bootstrapper and MSI files respectfully.

Also: installation would always be under elevated privileges, this is a safe assumption.

So I was trying to launch both setup.exe and app.msi in a way that installation is completely silent for cases when .NET is installed and not installed.

msiexec /i app.msi /qn

This works silently on machine that has .NET installed and silently fails on machine that does not have .NET installed.

Other combinations work non-silently or display some popups.

So is it possible to make such installation process silent? Or, at least, let .NET installation show popups but the application itself must be silent (also, there should be no other popups like "Setup is initializing components" etc, that are not related to .NET installation)

1

1 Answers

1
votes

The purpose of a bootstrapper is to install a chain of packages, usually a set of prerequisites (conditionally installed) then the main package. Yours isn't installing the prereq.

A cheap way to do this is to use a script (even as simple as a batch file) as the bootstrapper: detect .NET, run the .NET installer package if absent, then run the main package install:

@echo off
rem this key/value is how WiX detects .NET 4.0 Full installation
reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full" /v InstallPath >NUL 2>&1
rem sets ERRORLEVEL==0 if present, ERRORLEVEL==1 if absent

rem if .NET not found, install it:
if ERRORLEVEL 1 dotNetFx40_Full_setup.exe

rem now install main program
msiexec /i app.msi /qn

Caveats:

  • the Registry key names vary for different .NET versions
  • some sysadmins erase or disable the reg.exe command for security reasons
  • sometimes the .NET installer will reboot on you, and you won't get to the main package on the first try
  • a just-installed .NET Framework is sometimes not fully activated until after reboot
  • .bat files are very hackable. So is VBScript or JScript or whatever. Don't use them with real customers. A good bootstrapper (e.g. WiX burn) has .NET detection features built-in and is more opaque to black hats