简体   繁体   中英

Launch condition prevents silent installation (Application + .Net Framework)

I have added a Setup Deployment Project to my application in Visual Studio 2013 to generate a Setup Wizard for my application and a Setup.msi -File for offering a silent installation.

Executing msiexec /i "<PathToSetupDirectory>\\Setup.msi" /qb! works as expected. My app is installed silently. But my C#-Application depends on .Net-Framework 4.5.1. If this isn't installed a launch condition raises:

This setup requires the .NET Framework version VersionNumber. Please install the .NET Framework and run this setup again. The .NET Framework can be obtained from the Web. Would you like to do this now?

Of course I won't like to do this. This should work automatically.

So I selected the framework in Setup Deployment Project (right click) => Properties => Prerequisites... , checked "Download Prerequisites from the same location as my application" and added NDP451-KB2858728-x86-x64-AllOS-ENU.exe to the directory C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1A\\Bootstrapper\\Packages\\DotNetFX451 .

My wish is that the Setup.msi doesn't show the message of the launch condition if the framework hasn't been installed yet. It should simply install .Net Framework and the application afterwords without any user interaction. But it still shows up. Pressing No results in quitting the installation. Pressing Yes results in opening the browser and quitting the installation.

Of course I could write a bash-script that silently installs .Net Framework if necessary and starts the silent install of my app finally. But I would like to achieve this "the right way" . I have the feeling that i have missed something.

Any ideas?

The MSI install cannot also install the .NET Framework, mainly because an MSI setup can't recursively install another MSI setup (the NET FW). That's one of the reasons there are many prerequisites that must be installed prior to the MSI file, for which VS setups use setup.exe.

The setup.exe bootstrapper doesn't have a silent option as far as I know, but that's because many prerequisites don't have silent installs. There used to be a tool (Bootstrap Manifest Generator) that you could use to alter the embedded file containing the command line installs for prerequisites to make them silent:

https://msdn.microsoft.com/en-us/library/ms165429.aspx

so that may still be an option.

Another choice is to use the WiX bootstrapper tool "Burn" to create a bundle that will install the framework then your MSI silently. It's basically an Xml-driven specification of dependencies and your MSI fil.

Thx to PhilDW for getting this topic clear. Good to know that this is not possible with msi-files. I have read about the WiX bootstrapper tool "Burn" and the Bootstrap Manifest Generator and came to the conclusion to write a simple batch file. This will detect if a .Net Framework version 4.5.1 or later is installed - if not it is installed automatically. Afterwards the silent msi-install gets started.

silent_install.cmd :

@echo off
set forceNetFrameworkInstall=true

echo Starting silent installation of Setup.msi and its prerequisites ...

REG QUERY "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Release
if %ERRORLEVEL% EQU 0 (goto CHECK) else (goto INSTALL_DOTNET)

:CHECK
for /f "tokens=2*" %%a in ('REG QUERY "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Release') do set "releaseKeyHex=%%b"
set /A releaseKeyDec=%releaseKeyHex%
if %releaseKeyDec% GEQ 378675 set forceNetFrameworkInstall=false
if %forceNetFrameworkInstall% == true (
    echo Prerequisite: .Net Framework 4.5.1 or later version not detected
    goto INSTALL_DOTNET
) else (
    echo .Net Framework 4.5.1 or later version detected
    goto INSTALL_APP
)

:INSTALL_DOTNET
echo Installing .Net Framework 4.5.1 ...
%~dp0\DotNetFX451\NDP451-KB2858728-x86-x64-AllOS-ENU.exe /passive /norestart
echo Installing .Net Framework 4.5.1 Language Pack (German) ...
%~dp0\DotNetFX451\NDP451-KB2858728-x86-x64-AllOS-DEU.exe /passive /norestart
goto INSTALL_APP

:INSTALL_APP
echo Installing Application ...
msiexec /i %~dp0\Setup.msi /qb!
exit

This script reads the hex release-key of the currently installed .Net Framework (v4.X) and parses this key to a decimal number and compares it with the minimal release-key number of the prefered .Net Framework . Here you will find a list of these possible values: Detecting the .NET Framework (the higher the value the higher the .Net Framework version).

The script should be located in the following directory-tree:

|- setup.exe
|- Setup.msi
|- silent_install.cmd
|+ DotNetFX451
   |- NDP451-KB2858728-x86-x64-AllOS-DEU.exe
   |- NDP451-KB2858728-x86-x64-AllOS-ENU.exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM