目前知道2中方法。一个是用CustomAction的方式执行Exe,使用这种方式不仅仅可以安装net framework,而且还可以执行任何Exe程序。另一个是使用setup工程属性中的Prerequisites功能。
A. Custom Action
-
取得net分发包,可以在microsoft的网站上下载,是一个exe文件
-
在file system中加入这个Exe文件
-
进入custome action. 执行Add custome Action, 选择这个Exe.
-
在Custome Action中选中刚刚加入的文件,按F4,编辑属性。 Installer Class设置为false ;Arguments设置为命令行参数
Note: 命令行参数可以google到,下面是.net 3.0的命令行:
http://itgroup.blueshop.com.tw/joychen/blog?n=convew&i=1988
B. Prerequisites
参考
http://www.codeproject.com/KB/dotnet/Add_framework_in_setup.aspx
注意: 上面的文章在处理.net framework 3.5 sp1时有点问题,会编译不过。
解决方法:
- Navigate to the following URL: http://go.microsoft.com/fwlink?LinkID=118080
- Download the dotNetFx35.exe file to your local disk.
- Open a Command Prompt window and change to the directory to which you downloaded dotNetFx35.exe.
- At the command prompt, type:
dotNetFx35.exe /x:.
This will extract the Framework files to a folder named “WCU” in the current directory.
- Copy the contents of the WCU\dotNetFramework folder and paste them in the %Program Files%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder (%ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems). Note: Do not copy the WCU\dotNetFramework folder itself. There should be 5 folders under the WCU folder, and each of these should now appear in the DotNetFx35SP1 folder. The folder structure should resemble the following:
o DotNetFx35SP1 (folder)
- dotNetFX20 (folder
- dotNetFX30 (folder)
- dotNetFX35 (folder)
- dotNetMSP (folder)
- TOOLS folder)
- en (or some other localized folder)
- dotNetFx35setup.exe (file)
You may now delete the files and folders you downloaded and extracted in steps 2 and 4.
dotNetFx35.exe /x:.
This will extract the Framework files to a folder named “WCU” in the current directory.
o DotNetFx35SP1 (folder)
- dotNetFX20 (folder
- dotNetFX30 (folder)
- dotNetFX35 (folder)
- dotNetMSP (folder)
- TOOLS folder)
- en (or some other localized folder)
- dotNetFx35setup.exe (file)
You may now delete the files and folders you downloaded and extracted in steps 2 and 4.