Using Inno Setup with the .NET Framework
This article describes the script used to automatically download and install the Microsoft .NET Framework during the TimeSprite installation. Developers of .NET applications may find this information useful for their own applications.
The script is based heavily on the script Ted Ehrich posted to the Inno Setup newsgroup in this post: http://news.jrsoftware.org/news/innosetup.isx/msg06108.html
The script uses some of the third party add-ons to Innosetup, I think the QuickStart Pack includes what you need.
Requirements
Having the .NET Framework as a dependency makes the installation requirements somewhat complex.
- You need to detect whether the framework is already installed.
- The Framework needs to be installed by an administrator, but applications normally do not.
- You don’t want to distribute the framework with your application.
- You don’t want to force people to download the Framework if they don’t need to, ie. they have a local copy.
- The installation of the product should not go ahead if the .NET Framework installation fails or is cancelled.
The Script
The script that I ended up with performs the following processing:
- Requires Windows 98 or Windows NT4 or later. For simplicity it does not check for the required NT4 service pack or Internet Explorer 5.01 - I don’t think many systems that back level will be installing new software. However in testing I did verify that if the version of IE is too low, the .NET Framework installation asks for it to be upgraded.
- If the .NET Framework is not installed and the user is not logged on as an administrator, it tells the user they need an administrator to install the .NET Framework.
- If the .NET Framework is not installed, it looks for the dotnetfx.exe file in the same location as the setup file. If it is not found, it downloads it from Microsoft.
- Installs the .NET Framework if required.
- If the .NET Framework installation was successful or it was already installed, installs the application.
I haven’t programmed in Pascal, and this was my first shot at an Inno Setup script, so there are probably plenty of opportunities for tidying things up. A lot of what I did was just copying and modifying stuff. However the end result does seem to handle the .NET installation nicely.
Here is the script: dotnet.iss
Notes:
- The script is based on .NET Framework 1.1 but changes for other versions should be simple.
- The best way to check whether the .NET Framework is installed seems to be registry key ‘HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\policy\v1.1′. This key is accessible to regular users.
- If the .NET Framework download or installation fails or is cancelled, the installation goes back to the Ready to Install page. The user can restart the install, or cancel it.
- The URL for the .NET Framework download is hard coded. If it changes a new setup will be required. However it seems to be referenced in many places around the Internet, so hopefully Microsoft will think twice before changing it (famous last words…).
- If the user cancels the .NET Framework download partway through, then restarts the installation, the download resumes from where it was canceled. If they cancel the .NET Framework installation then restart the installation, it does not need to be downloaded again. (Both cases assume they did not exit the whole install).
- I have not tried to make the .NET install silent - I felt it was better to let the user see what is going on. The process can take a while.
Unrelated but perhaps useful information
I also have a digital photo program, Picnam, which I converted to the same process. Picnam adds entries to the “Open With” menu in Explorer, so that people can easily open images using Picnam but existing file associations are not affected.
These are the registry entries I used:
[Registry]
Root: HKCR; Subkey: “.jpg\OpenWithList\MyApp.exe”; Flags: uninsdeletekey noerror
Root: HKCR; Subkey: “.jpeg\OpenWithList\MyApp.exe”; Flags: uninsdeletekey noerror
Root: HKCR; Subkey: “applications\MyApp.exe\shell\open\command”; ValueType: string; ValueData: “”"{app}\MyApp.exe”" “”%1″”"; Flags: uninsdeletekey noerror
Root: HKCU; Subkey: "Software\Classes\.jpg\OpenWithList\MyApp.exe"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\Classes\.jpeg\OpenWithList\MyApp.exe"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\Classes\applications\MyApp.exe\shell\open\command"; ValueType: string; ValueData: """{app}\MyApp.exe"" ""%1"""; Flags: uninsdeletekey
The HKCR values install the “Open With” option for all users, but fail if the user is not an administrator. The HKCU values install it for the current user, and work even if the user is not an administrator.
VMWare
I used VMWare Workstation for the first time in testing the setup process, and I have to say it is a huge productivity booster for this type of thing. Using snapshots I was able to run the installation process with minor changes in various configurations over and over again - probably about 20 times in a couple of hours. It was a huge productivity gain, and I join those who say that VMWare or an equivalent product is an essential tool for software development.






14 Responses to “Using Inno Setup with the .NET Framework”
Thanks Andrew, this script helps me a lot in my project!
Thanks again!
What’s the URL to download the .NET 2.0 framework?
I don’t actually know. From memory, I found the 1.1 URL by downloading it from Microsoft. I searched on the URL, and found it was referenced in many places, so it seemed to be static.
It could change in the future though. It might actually be better to check the redistribution terms and host it yourself - the stats of how many people needed to install it might be interesting too.
If you find a URL for 2.0, I would be interested to know what it is.
Here is the download URL for 2.0. Not sure if it is a temporary one or not.
http://download.microsoft.com/download/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe
That looks like the one. It is also referenced in quite a few places on the web, so it looks like it is static.
I doubt that it is officially recognised by Microsoft, so if you use it it would pay to verify every so often that it still works, so you can update your installer if it moves.
the jackol’s den » Inno Setup with the .NET Framework - Mikhail Esteves - August 8, 2007
[...] blackhillsoftware.com [...]
Andrew,
Thank you for the article!
You might be interested in joining our Beta Tester Community and/or you would like to suggest some must-have features for Lexpa - Inno Setup integration for Visual Studio. If so please visit http://www.lexpa.com for details.
Thanks again!
Sincerely,
The Lexpa Team
wow, great script ! I was just looking for this !
Hello sir,
I am developer in software company. My problem is make the installation pakege in dotnet.
I create the manualy design my pakege
1.Install the frame work
2.ofter install my project to verify the user inter face go to next process
3.ofter install other frame work
thank you
Fiberglass flowers / Can’t run .NET bootstrapper from an MSI - April 5, 2008
[...] Now give up and go write own bootstrapper. I’m setiously considering going for InnoSetup deployment. [...]
Fiberglass flowers / Bootstrapper also can’t install your application after rebooting… - April 5, 2008
[...] Now give up and go write own bootstrapper. I’m setiously considering going for InnoSetup deployment. [...]
I have copied your article and modified it a little, just thought to let you know.
http://priyank.co.in/readarticle.php?article_id=17
You have done a great work.
Thanks.
The .NET blog » Installing the .NET framework along with your application - September 2, 2008
[...] framework to the clients computer, if it’s not already present. You can read more about it here and find the mentioned script here. I think that it’s a very elegant solution to a problem [...]
Hey i found the script that not only detects whether the computer has dotnet framework, it detects the previous version of the installed app, if present automatically uninstalls and installs the fresh copy, it also detects whether the specified application is up and running during installation if so appropriate action can be taken
http://www.ceveni.com/2008/03/check-dotnet-framework-using-innosetup.html
adding a few lines to script in the above link can be used to check the .net3.5
Thanks,
AB
Leave a Reply