Answer the question
In order to leave comments, you need to log in
Who has a WORKING InnoSetup script to deploy a .net application?
Good time everyone, I
ran into a number of problems when creating an installer for a .net application. The task is incredibly typical (and therefore should have many ready-made solutions): there is an application written in .net, it is necessary to ensure its performance on the maximum of systems. Including on Windows XP, which is why it came to use the minimum possible version of .net, namely 3.5. As I understand it, ClickOnce itself is written in .net, so I had to use InnoSetup. I check if .net is installed, if not, I install it. Everything seems to be simple. But there are problems:
1. In Windows XP, you also have to drag WindowsInstaller. The problem is that this is something I've found out empirically, and there may be other things to drag that I don't know about. For example, it is not clear whether this whole thing will work on Windows XP SP2. Will MS SQL + EF work on Windows XP.
2. For some reason, when you run the installed program on Windows 8, it swears that .net 3.5 is needed, while it comes built-in.
Who has a successful experience? Here is the current script:
#define MyAppName "SomeApp"
#define MyAppVersion "1.0"
#define MyAppPublisher "SomeCompany"
#define MyAppURL "SomeURL"
#define MyAppExeName "SomeFile.exe"
#define ThirdParty "libs\"
#define MSIFile "WindowsInstaller-KB893803-v2-x86.exe"
#define DotNetFile "DotNetFx35Client.exe"
[Setup]
AppId={{5E032C5B-4AAC-4F96-8C88-F662F09BCD48}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\SomeSoft {#MyAppVersion}
DefaultGroupName=SomeSoft {#MyAppVersion}
OutputDir=Output
OutputBaseFilename=SomeSoft {#MyAppVersion}
Compression=lzma
SolidCompression=yes
UsePreviousAppDir=yes
WizardImageFile=wizard.bmp
[Languages]
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "{#ThirdParty}\{#MSIFile}"; DestDir: {tmp}; Flags: deleteafterinstall; Check: MSI3IsNotInstalled; AfterInstall: InstallPackage('{tmp}\{#MSIFile}')
Source: "{#ThirdParty}\{#DotNetFile}"; DestDir: {tmp}; Flags: deleteafterinstall; Check: Framework35IsNotInstalled; AfterInstall: InstallPackage('{tmp}\{#DotNetFile}')
Source: "..\bin\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
const
// The minimum MSI version is 3.1.0.0
MinMSIVersionMS = (3 shl 16) or 1;
MinMSIVersionLS = (0 shl 16) or 0;
function MSI3IsNotInstalled : Boolean;
var
MSIVersionMS: Cardinal;
MSIVersionLS: Cardinal;
begin
Result := True;
if GetVersionNumbers(ExpandConstant('{sys}\msi.dll'), MSIVersionMS, MSIVersionLS) then
if MSIVersionMS >= MinMSIVersionMS then
Result := False;
end;
function Framework35IsNotInstalled(): Boolean;
var
bSuccess: Boolean;
flag: Cardinal;
begin
Result := True;
bSuccess := RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v3.5', 'Install', flag);
if (True = bSuccess) and (flag = 1) then
begin
Result := False;
end;
end;
procedure InstallPackage(FileName: String);
var
ResultCode: Integer;
StatusText: string;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Install libs...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant(FileName), '/q', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Error: ' + IntToStr(ResultCode) + '.', mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
end.
Answer the question
In order to leave comments, you need to log in
There are 2 types of framework, 3.5 and 3.5 client, only 3.5 client is installed by default, if you need to work on such systems, you need to change the environment.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question