正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!
您需要 登录 才可以下载或查看,没有账号?立即注册
x
Setup Factory。在7.0版本中,Setup Factory的默认从属资源中仅支持VB5.0及VB6.0,想要在生成的安装程序中自动完成.NET FRAMEWORK的安装,从网上查了一下,须要按以下步骤做几件事:
首先找到Setup Factory安装目录下的Dependencies目录,在目录中新建一个dotnet2_0.xml的文件。
然后,在Dependencies目录下新建子目录,取名dotnet2_0,将.NET FRAMEWORK安装程序dotnetfx.exe拷至该子目录下,dotnetfx.exe可在VS 2005的安装目录下的SDK\\v2.0\\BootStrapper\\Packages\\dotnetfx目录下找到。
完成之后打开Setup Factory,选择:资源---从属---添加,可以看到.NET FRAMEWORK 2.0了。
文件dotnet2_0.xml内容如下:
- <DependencyTemplate>
- <Dependency>
- <Name> .NET Framework 2.0</Name>
- <RuntimeTempFolder>dotnet20</RuntimeTempFolder>
- <RevisionDate>Friday, April 1, 2011</RevisionDate>
- <Description>Installs the Microsoft .NET 2.0 Framework SP2 onto the user's system. Includes the .NET installer in the setup executable.
-
- Applications and controls written for the .NET Framework version 2.0 require the .NET Framework Redistributable Package version 2.0 to be installed on the computer where the application or control runs. The .NET Framework redistributable package is available as a stand-alone executable file, dotnetfx3.exe. When this dependency module is included in your setup, it detects and installs the .NET Framework redistributable.
-
- This dependency module requires that you supply a copy of both Microsoft .NET Framework redistributable files (NetFx20SP2_x86.exe and NetFx20SP2_x64.exe). The .NET installation files can be downloaded from the following URL:
-
- http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5B2C0358-915B-4EB5-9B1D-10E506DA9D0F
-
- </Description>
- <DetectScript>function isDotNet_Installed()
- --Check to see if the registry key exists
- local DotNet_Registry = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727");
- if (DotNet_Registry == false) then
- -- The registry key does not exist
- -- Run the .NET Installation script
- -- Output to the log file that .NET could not be found, so it will be installed.
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: No version of .NET 2.0 was found. .NET 2.0 will be installed.\r\n", true);
- return false;
- else
- -- The key does exist
- -- Get the .NET install success value from the registry
- local DotNet_Install_Success = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", "Install", true);
-
- if (DotNet_Install_Success == "1") then
- -- Check the version key.
- local DotNet_Install_Version = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727", "Version", true);
-
- -- Compare the returned value against the needed value
- Compare = String.CompareFileVersions(DotNet_Install_Version, "2.2.30729");
-
- if (Compare == 0 or Compare == 1) then
- -- .NET version 2.0 SP2 is installed already
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: .NET version 2.0 SP2 is installed already\r\n", true);
- return true;
- end
- else
- -- The success value wasn't found
- -- Run the .NET Installation script
- -- Output to the log file that .NET could not be found, so it will be installed.
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: No version of .NET 2.0 was found. .NET 2.0 will be installed.\r\n", true);
- return false;
- end
- end
- return true;
- end</DetectScript>
- <DetectFunction>isDotNet_Installed</DetectFunction>
- <InstallScript>
- -- Check to see if this is a valid operating system for .NET 3.0
- function isValidDotNet2OS()
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: Entering compatible OS detection.\r\n",true);
-
- local tblOSInfo = System.GetOSVersionInfo();
- local strOSName = System.GetOSName();
-
- -- Check Windows XP
- if (tblOSInfo.MajorVersion == "5") and (tblOSInfo.MinorVersion == "1") then
- return true;
- end
-
- -- Check Windows Server 2003
- if (tblOSInfo.MajorVersion == "5") and (tblOSInfo.MinorVersion == "2") then
- return true;
- end
-
- -- this installer is not supported on other platforms
- return false;
- end
-
-
- if (not isDotNet_Installed()) then
- -- Variables used in the installation actions:
- local strMessage = [[Setup has detected that your Microsoft .NET run-time files are out of date.
-
- local strDialogTitle = "Technology Required";
- local bShowUserPrompt = true; -- Whether to prompt the user for confirmation before running the .NET installer.
- local bRunInstallFile = true; -- The default of whether or not to run the setup
- local bRequirementFail = false;
- local tbRequirementFailStrings = {};
-
- local strAbortQuestion = [[
-
- Due to this requirement failure, it is recommended that you abort the install.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- local strRequirementString = [[.NET 2.0 cannot be installed due to the following requirements:
-
- ]];
- local strRuntimeSupportFolder = SessionVar.Expand("%TempLaunchFolder%\\dotnet20");
- local b64BitOs = System.Is64BitOS();
- local strExtractInstallerToPath = "";
- if (b64BitOs) then
- --strExtractInstallerToPath = strRuntimeSupportFolder.."\\NetFx20SP2_x64.exe";
- strExtractInstallerToPath = strRuntimeSupportFolder.."\\dotnetfx2.0.exe";
- else
- strExtractInstallerToPath = strRuntimeSupportFolder.."\\dotnetfx2.0.exe";
- --strExtractInstallerToPath = strRuntimeSupportFolder.."\\NetFx20SP2_x86.exe";
- end
- local strMessageFail = "";
- local _NeedsReboot = false;
- local strCmdArgs = "";
- local bSilentMode = true; -- Whether to send the /q switch to the .NET 2.0 installer.
- local bVital = true; -- Whether the .NET 2.0 installation is vital.
-
- -- Output to the log that the .NET installation script has started.
- SetupData.WriteToLogFile("Success\t.NET 2.0 Module: Installation script started.\r\n", true);
-
- ------------------------------------------------------------------------------------------------------------
- ---- Requires Internet Explorer 6.0 greater
- ------------------------------------------------------------------------------------------------------------
-
- -- Read the version of Internet Explorer (if installed).
- strIEVersion = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Internet Explorer", "Version", false);
-
- -- If Internet Explorer Version is less than 6.00.2800.1106 , or cannot be found,
- -- set the failure variable and failure string table.
- if ((String.CompareFileVersions(strIEVersion, "6.00")== -1) or (strIEVersion == "")) then
- bRequirementFail = true;
- strTemp = "- .NET 2.0 requires Internet Explorer version 6.0 or greater.";
- Table.Insert(tbRequirementFailStrings, Table.Count(tbRequirementFailStrings) + 1, strTemp);
- end
-
- ------------------------------------------------------------------------------------------------------------
- ---- Requires Admin permissions ----
- ------------------------------------------------------------------------------------------------------------
-
- -- Check if the user is logged in with administrative permissions.
- -- If the user doesn't have admin permissions, set the failure variable
- -- and failure string table.
- tbUserInfo = System.GetUserInfo();
- if (tbUserInfo ~= nil) then
- if (not tbUserInfo.IsAdmin) then
- bRequirementFail = true;
- strTemp = "- You do not have the required administrative permissions to install .NET 2.0.";
- Table.Insert(tbRequirementFailStrings, Table.Count(tbRequirementFailStrings) + 1, strTemp);
- end
- end
-
- ------------------------------------------------------------------------------------------------------------
- ---- Requires MSI 3.1 ----
- ------------------------------------------------------------------------------------------------------------
- -- Get the operating system name.
- local strOSName = System.GetOSName();
-
- local strMSIVersion = MSI.GetMSIVersion();
-
-
- -- need MSI 3.1
- if (String.CompareFileVersions(strMSIVersion,"3.1.4000") == -1) or (not strMSIVersion) then
- -- MSI 3.1 is not installed
- bRequirementFail = true;
- strTemp = "- The .NET 2.0 runtime module requires Windows Installer 3.1. Please install this technology then run the setup again.";
- Table.Insert(tbRequirementFailStrings, Table.Count(tbRequirementFailStrings) + 1, strTemp);
- end
-
-
- ------------------------------------------------------------------------------------------------------------
- ---- Operating System Check
- -- Windows Server 2003
- -- Windows XP
- ------------------------------------------------------------------------------------------------------------
-
-
- -- Check if OS is Windows XP or Windows Server 2003
- if (not isValidDotNet2OS()) then
- bRequirementFail = true;
- --.NET 2.0 isn't supported on the OS that was detected.
- strTemp = "- .NET 2.0 cannot be installed on this operating system. Requires Windows XP, or Windows Server 2003.";
- Table.Insert(tbRequirementFailStrings, Table.Count(tbRequirementFailStrings) + 1, strTemp);
- end
-
-
- -- Check if the dialog should be displayed asking whether or not they want to install the module.
- if(bShowUserPrompt)then
- local nDialogResult = Dialog.Message(strDialogTitle,strMessage,MB_OKCANCEL,MB_ICONEXCLAMATION);
- if(nDialogResult == IDOK)then
- -- The user chose to install the module.
- bRunInstallFile = true;
- else
- -- The user chose not to install the module.
- bRunInstallFile = false;
- end
- end
-
- if (not bRequirementFail) then
- -- Check if the user wants to install the runtime.
- if(bRunInstallFile)then
- -- The following are command line options that can be used when launching the install file Dotnetfx3.exe.
- -- /q - Suppresses all UI. An .INI file cannot be specified with this option.
- -- /quiet - Same as /q.
- -- /qb - Displays minimal UI, showing only progress.
- -- /passive - Same as /qb.
- -- /uninstall - Uninstalls product.
- -- /remove - Same as /uninstall.
- -- /f - Repairs all .NET Framework 3.0 components that are installed.
- -- /nopatch - Specifies that patches are not applied and bypasses patch checking.
- -- /norollback - Specifies that setup is not rolled back if a setup component fails.
- -- /norestart - Specifies that the installer does not restart the computer after installation completes. The
- --redistributable installer returns ERROR_SUCCESS_REBOOT_REQUIRED (3010) if a reboot is required.
- --/? - Displays this list of options.
-
-
- if (bSilentMode) then
- -- Passing quite mode, and no restart.
- strCmdArgs = strCmdArgs.."/qb /norestart ";
- else
- -- Passing no restart.
- strCmdArgs = strCmdArgs.."/norestart ";
- end
- strCmdArgs = "/R:N";
- -- Output to the log that the .NET installation is being launched.
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: .NET 2.0 installation file "..strExtractInstallerToPath.." is being launched.\r\n");
- local nResult = File.Run(strExtractInstallerToPath, strCmdArgs, "", SW_SHOWNORMAL, true);
- if (nResult == 3010) then
- -- .NET install indicated that it needs reboot to be complete
- -- Set MSI Factory's reboot variable so that the reboot is just
- -- performed at the end of the install.
- _NeedsReboot = true;
- elseif (nResult == 1602) then
- -- The user canceled the setup program.
- strMessageFail = [[You have cancelled the installation for .NET 2.0. It is not recommended that you continue with the setup.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- elseif (nResult == 1603) then
- -- A fatal error occurred during installation.
- strMessageFail = [[A fatal error occurred during installation of the .NET 2.0 runtime. It is not recommended that you continue with the setup.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- elseif (nResult == 1605) then
- -- This action is only valid for products that are currently installed.
- strMessageFail = [[Error during installation of the .NET 2.0 runtime. This action is valid only for products that are currently installed. It is not recommended that you continue with the setup.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- elseif (nResult == 1636) then
- -- The patch package could not be opened or the patch was not applicable to the .NET Framework 3.0.
- strMessageFail = [[The patch package could not be opened or the patch was not applicable to the .NET Framework 2.0. It is not recommended that you continue with the setup.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- elseif (nResult == 1639) then
- -- Invalid command line argument.
- strMessageFail = [[An invalid command line argument was passed to the .NET 2.0 installation. It is not recommended that you continue with the setup.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- elseif (nResult == 1643) then
- -- The patch package is not permitted by system policy.
- strMessageFail = [[The .NET 2.0 patch package is not permitted by system policy. It is not recommended that you continue with the setup.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- elseif (nResult == 0) then
- -- The .NET setup was successful, so do nothing.
- else
- -- The .NET setup program was not completed successfully.
- strMessageFail = [[An unknown error occurred during the installation of the .NET 2.0 runtime. It is not recommended that you continue with the setup.
-
- Click OK to abort the setup, or Cancel to continue with the application install.]];
- end
-
- -- Check to see if an error message was generated.
- if (strMessageFail ~= "") then
- -- Display the error notification dialog.
-
- -- Output to the log .NET error message.
- SetupData.WriteToLogFile("Error\t.NET 2.0 Module: Dialog error shown- "..strMessageFail..".\r\n");
-
- if (bShowUserPrompt) then
- nDialogResult = Dialog.Message(".NET 2.0 Installation" ,strMessageFail,MB_OKCANCEL,MB_ICONEXCLAMATION);
- if (nDialogResult == IDOK) then
- bAbortInstall = true;
- end
- end
- end
-
- -- Delete the run time installer file and remove the temp folder
- File.Delete(strExtractInstallerToPath);
- --Folder.Delete(strRuntimeSupportFolder);
-
- -- If the user chose to abort the install after the failure of .NET install, exit the setup.
- if (bAbortInstall) then
- -- Output to the log that the user chose to abort the setup after .NET failure.
- SetupData.WriteToLogFile("Error\t.NET 2.0 Module: User chose to abort setup after .NET failure. Exiting setup.\r\n");
- Application.Exit(EXIT_REASON_USER_ABORTED);
- end
-
-
-
- else
- -- The user chose not to install the runtime so delete the run time installer file,
- -- remove the temp folder and then exit the setup.
-
- -- Output to the log that the user chose to abort the setup.
- SetupData.WriteToLogFile("Error\t.NET 2.0 Module: User chose to abort setup. Exiting setup.\r\n");
-
- File.Delete(strExtractInstallerToPath);
- --Folder.Delete(strRuntimeSupportFolder);
- if bVital then
- Application.Exit(EXIT_REASON_USER_ABORTED);
- else
- Application.ExitScript();
- end
- end
- else
- -- A requirement failed
-
- -- If the user didn't cancel...
- if (bRunInstallFile) then
- -- One or more of the requirements failed. Notify the user and ask if they wish
- -- to abort the installation.
- strFullErrorString = Table.Concat(tbRequirementFailStrings, "\r\n", 1, TABLE_ALL);
- nDialogResult = Dialog.Message("Notice" , strRequirementString..strFullErrorString..strAbortQuestion, MB_OKCANCEL, MB_ICONINFORMATION, MB_DEFBUTTON1);
-
- -- Output the requirement failure string to the log.
- SetupData.WriteToLogFile("Error\t.NET 2.0 Module: Requirement failure dialog: "..strFullErrorString.."\r\n");
-
- -- Delete the runtime installer file and remove the temp folder
- File.Delete(strExtractInstallerToPath);
-
- -- The user chose to abort the install due to the requirement failure of .NET.
- if (nDialogResult == IDOK) then
-
- -- Output to the log that the user chose to abort the install due to requirement failure.
- SetupData.WriteToLogFile("Error\t.NET 2.0 Module: User aborted setup due to requirement failure. Exiting setup.\r\n");
-
- -- Abort the install.
- Application.Exit(EXIT_REASON_USER_ABORTED);
- end
- else
- -- The user chose not to install the runtime so delete the run time installer file,
- -- remove the temp folder and then exit the setup.
-
- -- Output to the log that the user chose to abort the setup.
- SetupData.WriteToLogFile("Error\t.NET 2.0 Module: User chose to abort setup. Exiting setup.\r\n");
-
- File.Delete(strExtractInstallerToPath);
-
- if bVital then
- Application.Exit(EXIT_REASON_USER_ABORTED);
- else
- Application.ExitScript();
- end
-
- end
- end
-
- -- If a reboot was needed by .NET, notify the user that they must reboot
- -- before continuing with the install
-
- -- NOTE: If you would always like to force the user to reboot, comment out the "if (_NeedsReboot) then" condition below.
-
- local strRebootMessage = [[A reboot is required to continue with the installation. After rebooting, re-run the installation.
-
- Click OK to reboot now, or Cancel to reboot later.]];
- if (_NeedsReboot) then
- nDialogResult = Dialog.Message("Notice", strRebootMessage, MB_OKCANCEL, MB_ICONINFORMATION, MB_DEFBUTTON1);
-
- -- Output to the log that a reboot is required by the .NET setup.
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: .NET 2.0 detected that a reboot is required.\r\n");
- -- Check if the uer wanted to reboot now.
- if (nDialogResult == IDOK) then
-
- -- NOTE: If you would like the install to relaunch itself after the reboot,
- -- uncomment the following block of code.
- -- Re-run the installation after the reboot.
-
- File.RunOnReboot(_SourceFilename, "");
-
- -- Output to the log that a reboot will be performed.
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: A reboot will be performed.\r\n");
- -- Reboot the user's system.
- System.Reboot();
- Application.Exit(0);
- else
- -- Output to the log that the user chose to reboot later and abort the setup.
- SetupData.WriteToLogFile("Info\t.NET 2.0 Module: User chose to reboot later. Exiting setup.\r\n");
- -- Abort the install.
- Application.Exit(EXIT_REASON_USER_ABORTED);
- end
- end
- -- Output to the log that the installation script has finished.
- SetupData.WriteToLogFile("Success\t.NET 2.0 Module: Installation script finished.\r\n");
- end
- </InstallScript>
- <SupportFiles>
- <File>#SUFDIR#\Dependencies\dotnet20\dotnetfx2.0.exe</File>
- </SupportFiles>
- </Dependency>
- </DependencyTemplate>
复制代码 然后在 资源(resource)-从属(Dependencies)中添加.NET Framework 2.0就行了。在Actions—> on startup下面添加 下面代码 - result = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\policy\\v2.0");
- if (result == false) then
- result = File.Run(SessionVar.Expand("%TempLaunchFolder%\\dotnetfx2.0.exe"), "", "", SW_SHOWNORMAL, true);
- end
复制代码
|