Click here to Skip to main content
Email Password   helpLost your password?
Screenshot - dotnetfx_installer1.jpg

Screenshot - dotnetfx_installer3.jpg

Introduction

This article contains an InnoSetup install script that downloads (if setup files don't exist) and installs the .NET Framework 1.1/2.0/3.5 and its dependencies.

Background

Once upon a time, I needed an installer for my .NET applications. I knew that I could use the "genius" ClickOnce installer, but in my opinion it has a bad interface and is not very handy. Then I came across a script for InnoSetup that had everything I wanted, but unfortunately it was only for .NET 1.1. So, I spent a few hours (became more over time) in InnoSetup and modified it to my needs.

Details

The source code is written somewhat modular. The folder structure looks like this:

Screenshot - dotnetfx_content.jpg

Mostly you may have to tweak the setup.iss because of different Windows version / service pack version check depending on the version of .NET Framework you need.

If a dependency (product) is not installed, the script checks if the product's setup exists inside the dependencies directory, (.\MyProgramDependencies). If they don't exist there, it tries to download them (except for Windows Service Packs). This means a support for offline installing via CD or DVD is also possible. With the newest version, there was also support for 32-bit (x86) and 64-bit (x64) OS including Itanium (ia64) added.

Screenshot - dotnetfx_installer2.jpg

Screenshot - dotnetfx_installer4.jpg

The installation routine of the dependencies is automatic, and they run in quiet or semi quiet mode. Therefore no user interaction is needed, except for Internet Explorer 6. This script also uses [CostumMessages] so that you can easily add multi-language to your setup and may configure some settings (e.g. the dependencies directory) without looking at the [Code] part.

Applications used for the script are:

Known Problems

If dependencies are needed, the required free hard drive size is incorrect.

Points of Interest

Special thanks go to Ted Ehrich who created the .NET Framework 1.1 script. Well, I am sure that this script will serve me in the future very well and I hope you may like it too.

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralSetup for 32 and 64 bit
john5632
21:02 2 Feb '10  
Hi,

I saw code to create setup for 32 bit and 64 bit machine.
All things are same except source file name.

My question is :

If I have same exe to run on 32 and 64 bit machine and I want to create one setup, Shell i have to build in "ArchitecturesInstallIn64BitMode=x64 ia64".
GeneralMSI 4.5 ?
sikola
6:16 2 Feb '10  
Hi, does anybody have any suggestion for downloading Windows Installer 4.5 ?

Thanks
Petr
GeneralBug in installing kb835732 on win2000
zxpmyth
20:19 26 Jan '10  
I have downloaded Windows2000-KB835732-x86-CHS.exe. This commandline parameters for this app are now using:
/quit
/passive
/norestart
etc.

So, I changed those in kb835732.iss from
'/q:a /c:"install /q"'
to
'/passive /norestart'.

However, the function of
Exec(products[i].File, products[i].Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode)
in products.iss always got failed. That ResultCode didn't equate to 0.

The installation for dotnetfx20 is OK.
Thanks for any help.
GeneralInnoseup problem
tommy0987654321
22:29 15 Jan '10  
i downloaded the zip folder and i changed the files part with this part according to my need:
[Files]
Source: "C:\Users\Gautam\Documents\Visual Studio 2005\Projects\Final_Etech(Submit)\Final_Etech\bin\Debug\Final_Etech.exe"; DestDir: "{app}";
Source: "E:\Softy\DOT_NET\.NETFramework_2.0_Installer\dotnetfx.exe"; DestDir: "{app}";
Source: "C:\Users\Gautam\Documents\Visual Studio 2005\Projects\Final_Etech(Submit)\Final_Etech\bin\Debug\Etech.mdb"; DestDir: "{app}";
Source: "C:\Users\Gautam\Documents\Visual Studio 2005\Projects\Final_Etech(Submit)\Final_Etech\bin\Debug\AdminLogin.mdb"; DestDir: "{app}";
Source: "d:\Readme.txt"; DestDir: "{app}"; Flags: isreadme


also in some places i have to change the name of the .exe file........

but doing this is causing me problems with the .mdb file........

what should i do to the ,mdb file then?

please help

thank you
GeneralCode added, bug corrected
Vincent DUVERNET (Nolmë Informatique)
0:22 15 Jan '10  
Hi,

Great code guy Smile

i've added French support, Deutch x64 support for one patch.
i've changed some code in KB835732 to support English/Deutch/French and its arguments which wasn't correct

how can i submit it to you ?

----------------------------------------------

Under win2k Pro, it seems that multiple patch works bad (SP4 + patches without .NET):
- All is downloaded without any problem
- KB835732 has been installed but we have an error message at the end (so 3 patches are tagged as not deployed). But this patch appear in Add/removeprograms
So : I've checked in %WINDIR% : \$NtUninstallKB835732$ is present so patch is installed and ok.
- I launch setup again. Only .NET 2.0SP1 & language pack appear.
- Install failed again.
- I launch setup again. Only Language pack appear
- install OK, program OK.

I'm using 2.0 SP1 because 2.0SP2 is not compatible with Win2K.
Any idea ?
GeneralRe: Code added, bug corrected [modified]
Vincent DUVERNET (Nolmë Informatique)
1:30 15 Jan '10  
i've checked with WinXP Pro SP3 Fr. No problem, all is ok.
i've checked with Vista Pro SP2 Fr. Small problem, .NET2.0 don't exist so I think I must change setup to download .NET3.5 for Vista & 7
Here's the code :

//install .netfx 3.5 sp1 for Windows Vista, 7, 2008 Server
if minwinversion(6, 0) then begin
dotnetfx35sp1();
dotnetfx35sp1lp();
end else begin
//install .netfx 2.0 sp2 if possible; if not sp1 if possible; if not .netfx 2.0
if minwinversion(5, 1) then begin
// Window XP, 2003 Server
dotnetfx20sp2();
dotnetfx20sp2lp();
end else begin
// Windows 2000 SP4 support only .NET 2.0 SP1
if minwinversion(5, 0) and minwinspversion(5, 0, 4) then begin
kb835732();
dotnetfx20sp1();
dotnetfx20sp1lp();
end else begin
dotnetfx20();
dotnetfx20lp();
end;
end;
end;


But same problem as Win 2K Pro : .NET 3.5 failed but is installed. 2nd install will deploy Language pack.

modified on Friday, January 15, 2010 6:57 AM

Generalisxdl.dll fails to be loaded on win98 starting at least from ISTool 5.3.0
AceAce
5:21 8 Jan '10  
Dear stfx,
your article really rules!!!

I found a problem in isxdl.dll on win98:
-version 5.3.0 fails to be loaded
-version 5.1.5 is loaded successfully

So, when you write the requirements, i.e.

"Applications used for the script are:
* Inno Setup - setup engine (version 5.3.4)
* ISTool - extends Inno Setup but I just needed the isxdl.dll downloader (version 5.3.0)"

I think you should decide if support w98 or use ISTool 5.3.0
... this, of course, is valid if you have my same problem too ...

I tried to get in touch with the ISTool developer w/o success ...

Regards,
Ace
GeneralExcellent!
Ondra Spilka
3:10 18 Dec '09  
You save me lots of hours. Dealing with MS Setup and program data on W7 I recall Inno setup I used years ago...
Finished installation after 30 minutes even with MySQL and .NET35 prerequisity...
Gold medal for you...
GeneralVersion Comparison
Loki Man
2:47 1 Dec '09  
Hi guys,

I've noted that the version comparison in some cases does not work correctly, for example when installing on an pc the msi 3.1 cannot install because the version installed on it is greatter then the check but the check is returning that it's not.

Looking at the code, the comparison is just between strings ... so I think its better to improve this comparison to not fail ...

procedure msi31(MinVersion: string);
begin
// Check for required Windows Installer 3.0 on Windows 2000 or higher
if minwinversion(5, 0) and (fileversion(ExpandConstant('{sys}{\}msi.dll')) < MinVersion) then
AddProduct('msi31.exe',
'/qb /norestart',
CustomMessage('msi31_title'),
CustomMessage('msi31_size'),
msi31_url);
end;

I've improved to this one that gets the msi dll location from registry, but the comparison stills the same ... any tips on comparing versions ?

procedure msi31(MinVersion: string);
var
sMSIDll: string;
begin
// Check for required Windows Installer 3.0 on Windows 2000 or higher

if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion\Installer',
'InstallerLocation', sMSIDll) then
sMSIDll := sMSIDll + 'msi.dll' else
sMSIDll := ExpandConstant('{sys}{\}')+'msi.dll';



if minwinversion(5, 0) and (fileversion(sMSIDll) < MinVersion) then
AddProduct('msi31.exe',
'/quiet /norestart',
CustomMessage('msi31_title'),
CustomMessage('msi31_size'),
msi31_url);
end;
GeneralRe: Version Comparison
stfx
5:24 1 Dec '09  
the comparison may be between two strings but according to some tests pascal can compare them correctly.

e.g.

3.4 > 3.3.5 = true
3.4 > 3.4.1 = false


you could also split the string at '.' and compare each number but why should you do that if it is working already?

correct me if I am wrong

greetings
stfx
GeneralBug with kb835732 on Windows XP Prof
Batzen
17:22 5 Nov '09  
Your last recent version tries to install kb835732 on Windows XP, i think that is wrong.
I noticed that you removed the check for
exactwinversion(5, 0)
from the checks in kb835732.iss.
You should re-add that check.

Nice work!!!
GeneralRe: Bug with kb835732 on Windows XP Prof
stfx
5:30 1 Dec '09  
that is correct it should be

procedure kb835732();
begin
if exactwinversion(5, 0) and (minwinspversion(5, 0, 2) and maxwinspversion(5, 0, 4)) then begin
[...]
end;
end;

GeneralUrgent: Error installing .Net Framework 3.5 sp1 on Vista
Ant2100
1:54 30 Oct '09  
Dear stfx,

I have read through your article and used your scripts to provide the installation of the .Net Framework 3.5 sp1 in my installer if it is not present on the user's computer.

On a new Vista Home Premium machine, everything runs fine until after the .Net Framework is downloaded and goes through the process of installing the files. It comes up with an error page (in my installer) stating that an error has occured while trying to install the framework.

However, the strange thing is that after exiting the installer, under Add/Remove programs, the .Net Framework 3.5 sp1 is listed there as being installed. And, when I run the installer again it installs my program (without downloading the framework this time), which runs correctly.

So this leads me to believe that the Framework is being installed, only for some reason an error message is appearing stating the opposite. Could you kindly advise me on this issue?

Regards,
Anthony

P.S. Below is an extract from my InitializeSetup() function that deals with the prerequisites. Just to make sure that nothing is wrong in there. Also I am using the latest version of your code.

  	
//init windows version
initwinversion();

//check if dotnetfx35 can be installed on this OS
if not minwinspversion(5, 0, 3) then begin
MsgBox(FmtMessage(CustomMessage('depinstall_missing'), [CustomMessage('win2000sp3_title')]), mbError, MB_OK);
exit;
end;
if not minwinspversion(5, 1, 2) then begin
MsgBox(FmtMessage(CustomMessage('depinstall_missing'), [CustomMessage('winxpsp2_title')]), mbError, MB_OK);
exit;
end;

msi31('3.1');

dotnetfx35sp1();
dotnetfx35sp1lp();

Result := true;


Check out my desktop conversion software for Windows -
www.universalconverter.net

GeneralRe: Urgent: Error installing .Net Framework 3.5 sp1 on Vista
stfx
1:53 31 Oct '09  
Hey,

well I guess that problem occurs inside the InstallProducts function in products.iss

Here is a quick and a bit dirty fix. Replace the line 91
if ResultCode = 0 then
with the following:
if (ResultCode = 0) or (ResultCode = 3010) then


If we install any version of .net framework silently (/norestart) then the result code of 3010 tells us that a restart is required to complete the installation which indicates success.

Please tell me if that solves your problem.

Greetings
stfx
GeneralRe: Urgent: Error installing .Net Framework 3.5 sp1 on Vista
Ant2100
10:33 31 Oct '09  
Hey,

Thanks! That solved it! Smile

Kind regards,
Anthony

Check out my desktop conversion software for Windows -
www.universalconverter.net

QuestionPossible bug? Unknown type PChar
Stumproot
0:19 17 Sep '09  
On English Vista(64bit) my script works.
The same script breaks on line 5 in isxdl.iss with "Unknown type PChar" on Swedish Xp Home

Do you know how I might resolve this?
AnswerRe: Possible bug? Unknown type PChar
stfx
8:16 17 Sep '09  
If you use the unicode version of Inno Setup you have to replace PChar with PAnsiChar
GeneralRe: Possible bug? Unknown type PChar
McoreD
14:06 26 Sep '09  
Thanks stfx, that fixed it. Do you think any conditional statements can be put into this script so that users won't have to change this manually depending on what version of inno they installed. I appreciate that this is a new issue since 5.35. Thanks.
GeneralPrepareToInstall - stupid question ?
barabum
8:10 15 Sep '09  
Hello,

First of all, thank you for the nice work.

I'm new with INNO Setup, so all this might look stupid ... but i have some issues with the installer though. My dependencies (msi31.exe and dotnetfx35.exe) fail to install. I get no error message, the setup just skip them.

I did a little check and it might be a problem with the PrepareToInstall() function (where the InstallProducts() function it's called). I haven't found any call for PrepareToInstall().

So i called PrepareToInstall inside NextButtonClick and it does start msi31.exe but another problem appear. It seems that dotnetfx35.exe starts before msi31.exe finish it's installation and of course it fails (since dotnetfx35.exe require Windows installer 3.1).

I'll keep working on it, but a little push in the right direction will be much appreciated ... because i'm not really sure about what i'm doing Smile.

P.S. The /qb parameter doesn't work for Windows installer 3.1. So for the moment i'm using /quiet.
GeneralRe: PrepareToInstall - stupid question ?
stfx
8:23 17 Sep '09  
InstallProducts should be execute at the PrepareToInstall function inside products.iss.

Also the installation order depends on which main function was called first inside setup.iss
For example:
msi31('3.1');
dotnetfx35();


MSI 3.1 should be installed before .NET Framework 3.5

There could be some bugs though since I havent tested it heavily.
Btw are there any problems if you compile the original setup.iss (using .netfx 3.5)?
GeneralRe: PrepareToInstall - stupid question ?
barabum
1:23 18 Sep '09  
I partially solved the problem, it was mainly because of my INNO Setup version. It was older than 5.3.2 where this PrepareToInstall was added as an event function.

After the upgrade to the last version, if i remove the manual call for PrepareToInstall, it's installing msi31 correctly but fail to install dotnetfx35 (the order it's exactly like you said). I kind of solved that too by calling PrepareToInstall again inside the NextButtonClick function. I don't know why i have to call PrepareToInstall again to make it work, so i'll keep checking ... but for the moment it's the only solution i found.

And yes, the original setup.iss have the same problem ... it's installing msi31, but then fail on dotnetfx35.
QuestionWrong options
alex_ger
10:37 14 Sep '09  
Hello,
I think there are wrong options for installing .NET 2.0 + .NET 2.0 SP1 (see dotnetfx20.iss and dotnetfx20sp1.iss).
I had some issues during installation and recognized that there are parameters which do not exist (that’s what the syntax dialog said).
I replace it with "/qb /norestart /lang:ENU" and everything works fine.

Alex
Generalcheck for file is use
Brandon Holland
4:47 9 Sep '09  
is there away to get a check for file in use within this program?


I have been using this http://raz-soft.com/display-english-posts-only/issproc-v102-files-in-use-extension-for-inno-setup/[^] but how would I get this added in with this code?


Thanks
GeneralRe: check for file is use
stfx
9:10 9 Sep '09  
Sorry but I am not familiar with that extension.

But it is a good idea so I may implement it in the next version.
QuestionOffline files
alex_ger
13:40 8 Sep '09  
Thank you very much for your script. I love it!
But I have some questions regarding the "offline files".

1. Why do you/we have to rename the files (org. "NetFx20SP1_x86.exe" -> "dotnetfx20sp1.exe")? This seems to be unnecessary because these files are neutral for different languages.
2. Do I have any possibilies to put files for different platforms in the dependency folder? For example NetFx20SP1_ia64.exe, NetFx20SP1_x64.exe and NetFx20SP1_x86.exe and your script selects the right one? Or do I have to build 3 setups for each platform?

Greetings from munich
Alex


Last Updated 2 Sep 2009 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010