简体   繁体   English

启动条件阻止静默安装(Application + .Net Framework)

[英]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. 我已在我的Visual Studio 2013中的应用程序中添加了安装程序部署项目,以为我的应用程序生成一个安装向导,并为提供静默安装生成一个Setup.msi -File。

Executing msiexec /i "<PathToSetupDirectory>\\Setup.msi" /qb! 执行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. 但是我的C#-Application依赖于.Net-Framework 4.5.1。 If this isn't installed a launch condition raises: 如果未安装,则会出现启动条件:

This setup requires the .NET Framework version VersionNumber. 此设置需要.NET Framework版本VersionNumber。 Please install the .NET Framework and run this setup again. 请安装.NET Framework,然后再次运行此安装程序。 The .NET Framework can be obtained from the Web. 可以从Web获得.NET Framework。 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 . 因此,我在Setup Deployment Project (right click) => Properties => Prerequisites...选择了框架Setup Deployment Project (right click) => Properties => Prerequisites... ,选中“从与我的应用程序相同的位置下载先决条件”,并添加了NDP451-KB2858728-x86-x64-AllOS-ENU.exe到目录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. 我的希望是,如果尚未安装框架,Setup.msi不会显示启动条件的消息。 It should simply install .Net Framework and the application afterwords without any user interaction. 它应该只安装.Net Framework和应用程序后记,而无需任何用户交互。 But it still shows up. 但是它仍然显示出来。 Pressing No results in quitting the installation. No(否)会导致退出安装。 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. 当然,如果需要,我可以编写bash脚本以静默方式安装.Net Framework并最终开始以静默方式安装我的应用程序。 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). MSI安装程序也不能安装.NET Framework,主要是因为MSI安装程序不能递归安装其他MSI安装程序(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. 这是在MSI文件之前必须安装许多先决条件的原因之一,VS安装程序为此使用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. 据我所知,setup.exe引导程序没有静默选项,但这是因为许多先决条件没有静默安装。 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: 曾经有一个工具(Bootstrap清单生成器),您可以使用该工具来更改嵌入式文件,该嵌入式文件包含用于使其静默的前提条件的命令行安装:

https://msdn.microsoft.com/en-us/library/ms165429.aspx 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. 另一个选择是使用WiX引导程序工具“ Burn”创建一个捆绑包,该捆绑包将以静默方式安装框架,然后安装MSI。 It's basically an Xml-driven specification of dependencies and your MSI fil. 它基本上是Xml驱动的依赖项和MSI文件的规范。

Thx to PhilDW for getting this topic clear. 感谢PhilDW澄清此主题。 Good to know that this is not possible with msi-files. 很高兴知道这对于msi文件是不可能的。 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. 我已经阅读了有关WiX引导程序工具“ Burn”和Bootstrap清单生成器的信息,并得出了编写简单批处理文件的结论。 This will detect if a .Net Framework version 4.5.1 or later is installed - if not it is installed automatically. 这将检测是否安装了.Net Framework 4.5.1或更高版本-如果未安装,则会自动安装。 Afterwards the silent msi-install gets started. 之后,静默msi-install开始。

silent_install.cmd : 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 . 该脚本读取当前安装的.Net Framework(v4.X)的十六进制发布密钥,并将该密钥解析为十进制数字,然后将其与首选.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). 在这里,您将找到这些可能值的列表: 检测.NET Framework (值越高,.Net Framework版本越高)。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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