杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2793|回复: 0

Setup Factory 7.0 打包.NET FRAMEWORK 2.0

[复制链接]
发表于 2017-3-29 13:48:31 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
    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内容如下:
  1. <DependencyTemplate>   
  2.   
  3. <Dependency>   
  4.   
  5. <Name>Microsoft .NET Framework 2.0</Name>   
  6.   
  7. <RuntimeTempFolder>dotnet2_0</RuntimeTempFolder>   
  8.   
  9. <RevisionDate>Friday, March 30, 2007</RevisionDate>   
  10.   
  11. <Description>安装 Microsoft .NET Framework 2.0应用程序所需的运行时文件。</Description>   
  12.   
  13. <DetectScript>   
  14.   
  15. function isDotNet_Installed()   
  16.   
  17. --author:zhengxinhe www.admans.net   
  18.   
  19. -- Output to the log that the .NET detection has started.   
  20.   
  21. SetupData.WriteToLogFile("Success/t.NET 2.0 Module: Detection script started./r/n", true);   
  22.   
  23. -- Get the operating system name.   
  24.   
  25. --Check to see if the registry key exists   
  26.   
  27. DotNet_Registry = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software//Microsoft//.NETFramework");   
  28.   
  29. if (DotNet_Registry == nil) then   
  30.   
  31. -- The registry key does not exist   
  32.   
  33. -- Run the .NET Installation script   
  34.   
  35. -- Output to the log file that .NET could not be found, so it will be installed.   
  36.   
  37. SetupData.WriteToLogFile("Info/t.NET 2.0 Module: No version of .NET 2.0 files was found. .NET 2.0 will be installed./r/n", true);   
  38.   
  39. return false;   
  40.   
  41. end   
  42.   
  43. -- The key does exist   
  44.   
  45. -- Get the .NET install location from the registry   
  46.   
  47. DotNet_Install_Location = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software//Microsoft//.NETFramework", "InstallRoot", true);   
  48.   
  49. -- Look for the file mscorcfg.dll   
  50.   
  51. Does_File_Exist = DotNet_Install_Location.."//v2.0.50727//aspnet_rc.dll";   
  52.   
  53. if(not File.DoesExist(Does_File_Exist))then   
  54.   
  55. -- The file does not exist   
  56.   
  57. -- Run the .NET Installation script   
  58.   
  59. -- Output to the log file that .NET could not be found, so it will be installed.   
  60.   
  61. SetupData.WriteToLogFile("Info/t.NET 2.0 Module: No version of .NET 2.0 file was found. .NET 2.0 will be installed./r/n", true);   
  62.   
  63. return false;   
  64.   
  65. end   
  66.   
  67. -- The file does exist   
  68.   
  69. -- Get the version of mscorcfg.dll   
  70.   
  71. msc_ver = File.GetVersionInfo(Does_File_Exist);   
  72.   
  73. if(not msc_ver)then   
  74.   
  75. SetupData.WriteToLogFile("Info/t.NET 2.0 Module: no version was found. .NET 2.0 will be installed./r/n", true);   
  76.   
  77. return false;   
  78.   
  79. end   
  80.   
  81.   
  82.   
  83. -- Compare the returned value against the needed value   
  84.   
  85. Compare = String.CompareFileVersions(msc_ver.FileVersion, "2.0.50727.42");   
  86.   
  87. if (Compare == -1) then   
  88.   
  89. -- Output to the log file that a lesser version of .NET was found on the system   
  90.   
  91. SetupData.WriteToLogFile("Info/t.NET 2.0 Module: A lesser version of .NET 2.0("..msc_ver.FileVersion..") was found on the users system./r/n", true);   
  92.   
  93. return false;   
  94.   
  95. else   
  96.   
  97. -- a version less than version 2.0 is installed   
  98.   
  99. -- Output to the log file that a lesser version of .NET was found on the system   
  100.   
  101. SetupData.WriteToLogFile("Info/t.NET 2.0 Module: A new or this version of .NET 2.0 was found on the users system./r/n", true);   
  102.   
  103. return true;   
  104.   
  105. end   
  106.   
  107. end   
  108.   
  109. </DetectScript>   
  110.   
  111. <DetectFunction>isDotNet_Installed</DetectFunction>   
  112.   
  113. <InstallScript>   
  114.   
  115. -- 用在安装操作中的变量:   
  116.   
  117. local strMessage = [[安装程序检测到你的系统没有安装Microsoft .NET Framework2.0或者版本过旧。请点击“确定”进行安装,点击“取消”中止安装。]];   
  118.   
  119. local strDialogTitle = "必需的技术文件";   
  120.   
  121. local bShowUserPrompt = true; -- 设置为 true 来询问用户是否安装模块   
  122.   
  123. local bRunInstallFile = true; -- 设置默认选择 (是否默认运行安装)   
  124.   
  125. local strRuntimeSupportFolder = SessionVar.Expand("%TempLaunchFolder%//dotnet2_0");   
  126.   
  127. local strFileToRun = strRuntimeSupportFolder.."//dotnetfx.exe";   
  128.   
  129. -----------------------------------------------------------------------------------------   
  130.   
  131. -- 安装已启动。   
  132.   
  133. SetupData.WriteToLogFile("成功/tdotnet2_0 模块:安装脚本已启动。/r/n", true);   
  134.   
  135. -- 删除临时文件和运行时支持文件夹 (同时进行错误检查)   
  136.   
  137. local function PerformCleanUp()   
  138.   
  139. File.Delete(strFileToRun);   
  140.   
  141. error = Application.GetLastError();   
  142.   
  143. if error ~= 0 then   
  144.   
  145. SetupData.WriteToLogFile("错误/tdotnet2_0 模块:无法删除临时文件 (".._tblErrorMessages[error]..")/r/n", true);   
  146.   
  147. end   
  148.   
  149. Folder.Delete(strRuntimeSupportFolder);   
  150.   
  151. error = Application.GetLastError();   
  152.   
  153. if error ~= 0 then   
  154.   
  155. SetupData.WriteToLogFile("错误/tdotnet2_0模块:无法删除临时文件夹 (".._tblErrorMessages[error]..")/r/n", true);   
  156.   
  157. end   
  158.   
  159. end   
  160.   
  161. -- 是否显示对话框来询问用户是否安装模块。   
  162.   
  163. if(bShowUserPrompt)then   
  164.   
  165. local nDialogResult = Dialog.Message(strDialogTitle,strMessage,MB_OKCANCEL,MB_ICONEXCLAMATION);   
  166.   
  167. if(nDialogResult == IDOK)then   
  168.   
  169. -- 用户选择安装模块。   
  170.   
  171. bRunInstallFile = true;   
  172.   
  173. -- 用户要安装它   
  174.   
  175. SetupData.WriteToLogFile("成功/tdotnet2_0 模块:用户已确认,准备安装。/r/n", true);   
  176.   
  177. else   
  178.   
  179. -- 用户不安装模块。   
  180.   
  181. bRunInstallFile = false;   
  182.   
  183. -- 用户回答否   
  184.   
  185. SetupData.WriteToLogFile("成功/tdotnet2_0 模块:用户不安装模块。/r/n", true);   
  186.   
  187. end   
  188.   
  189. end   
  190.   
  191. -- 检查用户是否要安装运行时。   
  192.   
  193. if(bRunInstallFile)then   
  194.   
  195. -- 开始!   
  196.   
  197. SetupData.WriteToLogFile("成功/tdotnet2_0模块:正在运行dotnet2_0 安装程序。/r/n", true);   
  198.   
  199. -- “/R:N”命令行参数告诉 VB 安装程序若需要的话不要显示重启屏幕。   
  200.   
  201. -- 我们将检测整个安装进程返回代码,若需要的话,还设置内部 _NeedsReboot 变量。   
  202.   
  203. -- 【注意】在静默方式下,你不能添加命令行参数“/Q”来运行安装   
  204.   
  205. local nResult = File.Run(strFileToRun,"/R:N","",SW_SHOWNORMAL,true);   
  206.   
  207. if(nResult == 3010)then   
  208.   
  209. -- VB 安装指明它需要重启才能完成   
  210.   
  211. -- 设置 Setup Factory 的重启变量,以便在安装结束时重启   
  212.   
  213. _NeedsReboot = true;   
  214.   
  215. -- 需要重启   
  216.   
  217. SetupData.WriteToLogFile("成功/tdotnet2_0 模块:dotnet2_0 安装程序已告知它需要重启。/r/n", true);   
  218.   
  219. end   
  220.   
  221. -- 删除运行时安装程序文件,并删除临时文件夹   
  222.   
  223. PerformCleanUp();   
  224.   
  225. -- 全部完成!   
  226.   
  227. SetupData.WriteToLogFile("成功/tdotnet2_0模块:dotnet2_0运行时安装完毕。/r/n", true);   
  228.   
  229. else   
  230.   
  231. -- 用户不想安装运行时,那么删除运行时安装程序文件,   
  232.   
  233. -- 并删除临时文件夹,然后退出安装程序。   
  234.   
  235. PerformCleanUp();   
  236.   
  237. -- 全部完成!   
  238.   
  239. SetupData.WriteToLogFile("成功/tdotnet2_0 模块:dotnet2_0 运行时未安装。/r/n", true);   
  240.   
  241. Application.Exit();   
  242.   
  243. end   
  244.   
  245. </InstallScript>   
  246.   
  247. <SupportFiles>   
  248.   
  249. <File>#SUFDIR#/Dependencies/dotnet2_0/dotnetfx.exe</File>   
  250.   
  251. </SupportFiles>   
  252.   
  253. </Dependency>   
  254.   
  255. </DependencyTemplate>   
复制代码

二 安装后完成以下操作
1.注册dll 2..net工具安装服务 3.net命令启动服务
在屏幕 - 安装之后 - 结束安装 - 编辑 - 操作 - On Next中,加入以下几行
  1. Shell.Execute("regsvr32", "open",  SessionVar.Expand(" /s %WindowsFolder%//System32//zkemkeeper.dll"), "", SW_SHOWNORMAL);  
  2. Shell.Execute(SessionVar.Expand("%WindowsFolder%//Microsoft.NET//Framework//v2.0.50727//InstallUtil.exe"), "open", " MyService.exe /i", SessionVar.Expand("%AppFolder%"), SW_SHOWNORMAL);  
  3. Application.Sleep(3000);  
  4. Shell.Execute("net", "open", " start myservice", "", SW_SHOWNORMAL);  
复制代码

三 卸载后完成以下操作
1.停止服务 2.卸载服务 3.等文件不在使用时开始执行卸载
在卸载 - 操作 - On Pre Unistall中,加入以下几行
  1. Shell.Execute("net", "open", " stop myservice", "", SW_SHOWNORMAL);  
  2. Shell.Execute(SessionVar.Expand("%WindowsFolder%//Microsoft.NET//Framework//v2.0.50727//InstallUtil.exe"), "open", " MyService.exe /u", SessionVar.Expand("%AppFolder%"), SW_SHOWNORMAL);  
  3. repeat  
  4.     s = File.IsInUse(SessionVar.Expand("%AppFolder%//MyService.exe"));  
  5. until not s  
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-4-28 06:28 , Processed in 0.107201 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表