MSI Installer - conditional installation of prerequisites - c#

I had a problem with SAP Crystal Reports SDK. It disappeared from web, so i had to create my own ClickOnce Bootstrapper package (for that I've used software called Bootstrap generator).
And its almost working as expected, it install SAP Crystal Report before installing main program.
The problem is that it is installing SAP Crystal Report everytime i run installer, even when its already installed.
It looks like my MSI installer doesnt detect that there is already installed version of SAP Crystal Report.
Product.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Product ProductCode="SAP.Crystal.reports.x86" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
<PackageFiles CopyAllPackageFiles="false">
<PackageFile Name="crruntime_32bit_13_0_15.msi" PublicKey="3082010A0282010100A5F02AFCBAF295DD82C482B0AA83782A08EA007635AFE2E76B57558D6AD708A1C96B86DA81894CDBB42214C26674A5C7F233D8BC76C77B3B2CBC8E38033C3C9C26FC5CD0789A462A2A6B2B19AC9321C851A08544DBF42CE697C97B730964C159D533BA56B835B702AA3F30E96CFD76F60A555EBC862828347E468BF126B9EB345A7E488AEA3451E9E9EB8412A600D1DB811A2C0144697048CD41F100E10AB8225658E1C3B7613A06835E628E2556C0F8BFD1408A0A5FED97892F6B99F49F2F436A0293AA5562FBBD5EE89DC667261E058AA767E168867CEAC2081588C1BD800FC2BFCD98773CEFD3266F54EB0DC7DAF4D5CD1867EA897D39E6A289A4A75ECA890203010001" />
</PackageFiles>
<Commands Reboot="Defer">
<Command PackageFile="crruntime_32bit_13_0_15.msi">
<ExitCodes>
<DefaultExitCode Result="Success" String="Anunexpectedexitcodewasr" FormatMessageFromSystem="true" />
</ExitCodes>
</Command>
</Commands>
</Product>
Package.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Package Name="DisplayName" Culture="Culture" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
<Strings>
<String Name="Culture">pl</String>
<String Name="DisplayName">SAP Crystal reports x86</String>
<String Name="Anunexpectedexitcodewasr">An unexpected exit code was returned from the installer. The installation failed.</String>
</Strings>
</Package>
Prerequsities properties:

If you want to check if a prerequisite is already installed, you will need to add 2 things to the product.xml file.
First thing is the product code, or registry key.
If you pick a product code you could add an MSI Install check, for example:
<InstallChecks>
<MsiProductCheck Property="CR32BitExists" Product="{9D52DBF3-229A-4723-BF31-C57C9C1D2A23}" />
<MsiProductCheck Property="CR64BitExist" Product="{8055CFEA-3871-4C76-A321-E32F63637CC4}" />
</InstallChecks>
Then you would have to add install conditions, for example (for x86):
<InstallConditions>
<BypassIf Property="CR32BitExists" Compare="ValueEqualTo" Value="1" />
<BypassIf Property="CR32BitExists" Compare="ValueGreaterThanOrEqualTo" Value="3" />
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel" />
</InstallConditions>
Notice that CR32BitExists is declared in Install checks and is used in InstallConditions.
About used values (1,3) you can read about here:
https://learn.microsoft.com/en-us/windows/win32/msi/session-featurerequeststate
After modifying product.xml you need to rebuild your msi.
When you try to install it, it will look for mentioned product codes in Install Checks.
If it detects it installed in OS, it will bypass instalation.

Related

Include .exe file when deploying wpf application

I'm creating a WPF application that uses also the Kinect 2. Now it's time to publish my application and I would like to create a unique setup file that installs the application and the Kinect SDK. I have the Kinect .exe and I would like to include it in the standard setup I create with the publish option in Visual studio (btw I'm using Visual Studio 2017).
Reading some stuff I figure out that the right way could be to insert the Kinect SDK in the prerequisites of my application. Right?
Thus I'm trying to add the file, following these guides:
How to: Create a Package Manifest
How to: Create a Product Manifest
I have created a folder in C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages, I have added the product xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Custom.Bootstrapper.Package">
<PackageFiles>
<PackageFile Name="KinectRuntime-v2.0_1409-Setup.exe"/>
</PackageFiles>
<Commands>
<Command PackageFile="KinectRuntime-v2.0_1409-Setup.exe" Arguments="">
<InstallConditions>
<BypassIf Property="IsMsiInstalled"
Compare="ValueGreaterThan" Value="0"/>
<FailIf Property="AdminUser"
Compare="ValueNotEqualTo" Value="True"
String="NotAnAdmin"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" String="GeneralFailure"/>
</ExitCodes>
</Command>
Then in a subfolder called "en" I added the package xml file:
<Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
Name="DisplayName"
Culture="Culture"
LicenseAgreement="SDKEula.rtf">
<PackageFiles>
<PackageFile Name="SDKEula.rtf"/>
</PackageFiles>
<!-- Defines a localizable string table for error messages. -->
<Strings>
<String Name="DisplayName">Update Consent Dialog</String>
<String Name="Culture">en</String>
<String Name="AU_Unaccepted">The automatic update agreement is not accepted.
</String>
<String Name="GeneralFailure">A failure occurred attempting to launch the setup.</String>
</Strings>
</Package>`
I also added the rtf file. So for me should be almost ok. But when I go back to VS I don't see this new package in the prerequisites list.
Can you help me to add the Kinect SDK installer?
Thank you very much,
Alex
Solved. I thought that the folder was right but instead looking in the key GenericBootstrapper I found that the packages' path was C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper. Adding the new package with the product and package xml in the folder I'm able to see the Kinect Installer in the prerequisites. Publishing the APP everything works

WIX: Unable to perform Major Upgrade using Orca at run time

I am using WIX to create a MSI file . The Problem is even if I change its Package code and Product code without changing upgrade code using ORCA , it is not doing Major Upgrade previous version , rather it creates an new independent instance. But when I create new MSI with same upgrade code it successfully upgrades previous instance rather than creating new one.
Below are my product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="PranaNirvana" Language="1033" Version="1.7.1.35" Manufacturer="Nirvana Solutions" UpgradeCode="5f546b4e-65b3-42d3-b4f3-f7153319dedc">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="yes" />
Is there any other parameter to change in order to create a Major Upgrade?

How to Combine WIX Setup Project with WIX Bootstrapper Project

I have a WIX Setup Project that includes my custom UI and a WIX Bootstrapper Project that includes prerequsites/dependencies in form of exe and Msi of my projects.
I want to combine them to make a single exe.
If i give reference of my WIX Setup project in Bootstrapper Project then it did not display my WIX UI. However it is able to successfully installed my setup msi and prerequisites.
<Bundle Name="Bootstrapper1" Version="1.0.0.0" Manufacturer="Microsoft" UpgradeCode="4056d930-16b2-44eb-a861-16db566ae44c">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<PackageGroupRef Id="Y"/>
<MsiPackage SourceFile ="$(var.BiodentifySetUp.TargetPath)" Compressed ="yes" />
</Chain>
</Bundle>
<Fragment>
<PackageGroup Id="Y">
<ExePackage Id="Y" DisplayName="software already install"
DownloadUrl="http://download.microsoft.com/download/5/6/2/562A10F9-C9F4-4313-A044-9C94E0A8FAC8/dotNetFx40_Client_x86_x64.exe"
Compressed="no" Cache="yes" PerMachine="yes" Permanent="yes"
Vital="yes" SourceFile=".\y.msi" InstallCommand="/passive /norestart" />
</PackageGroup>
</Fragment>
How can I merge them to make an exe?
what i beleive you want to do is to use single exe to install all dependencies and your own msi and show your own MSI UI when it comes time to install your .msi packageand if I am not wrong with then you simply need to add DisplayInternalUI='yes' to the MsiPackage elements you want to display.
For example:
<Chain>
...
<MsiPackage ... DisplayInternalUI='yes' />
</Chain>
and if it is like you want NO bootstrapper UI but only your MSI UI then there is no such bootstrapper application who will silently install your dependencies and will show your MSI UI.
Please clearly explain your requirement for better responses.

How to install visual studio 2010 setup project with MS Access database on a computer which is not having Office 2010 installed?

I am developing wpf application in C#. I have successfully created the setup project for wpf application in visual studio 2010. I have used MS Access 2010 as a database. It install fine on all computers. But on some computer there is no Microsoft Office installed and on some computer there is lower version of MS Office like MS Office 2003. When I install my application on these computers it gives me connectivity issues. Can you please tell me what should I need to do ? Should I need to include any prerequisite for MS Access 2010 in visual studio 2010 setup project ? If there is any which are they and how to include them ?
I had same problem but I have already created a Bootstrapper package for Microsoft Access Database Engine 2010. I've also included in this package x64 version of it. So it should work on 64 machine also. To include any Prerequisites you must have to add a Bootstrapper Package of that. After that you can get that in your Prerequisite list. That already you know I think. To build a Bootstrapper you need 2 manifest XML files. 1 is product.xml and another is package.xml right? I'm writing all the XML script below.
PRODUCT XML:
<Product
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Access.Database.Engine.2010"
>
<!-- Defines list of files to be copied on build -->
<PackageFiles CopyAllPackageFiles="false">
<PackageFile Name="AccessDatabaseEngine.exe" HomeSite="http://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe" />
<PackageFile Name="AccessDatabaseEngine_x64.exe" HomeSite="http://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_x64.exe" />
</PackageFiles>
<RelatedProducts>
<DependsOnProduct Code="Microsoft.Net.Framework.2.0" />
</RelatedProducts>
<InstallChecks>
<MsiProductCheck Property="IsInstalled"
Product="{90140000-00D1-0409-0000-0000000FF1CE}"/>
</InstallChecks>
<Commands>
<Command PackageFile="AccessDatabaseEngine.exe"
Arguments='/passive'>
<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<!-- ByPass if the Processor is not x86 -->
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/>
<!-- ByPass if we have installed -->
<BypassIf Property="IsInstalled" Compare="ValueGreaterThan" Value="0" />
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on Win95 -->
<FailIf Property="Version9x" Compare="VersionLessThan" Value="4.10" String="InvalidPlatformWin9x"/>
<!-- Block install on NT 4 or less -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.00" String="InvalidPlatformWinNT"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
<Command PackageFile="AccessDatabaseEngine_x64.exe"
Arguments='/passive'>
<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<!-- ByPass if the Processor is not x64 -->
<BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="AMD64"/>
<!-- ByPass if we have installed -->
<BypassIf Property="IsInstalled" Compare="ValueGreaterThan" Value="0" />
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on Win95 -->
<FailIf Property="Version9x" Compare="VersionLessThan" Value="4.10" String="InvalidPlatformWin9x"/>
<!-- Block install on NT 4 or less -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.00" String="InvalidPlatformWinNT"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1641" Result="SuccessReboot"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>
</Product>
PACKAGE XML:
<?xml version="1.0" encoding="utf-8" ?>
<Package
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
Name="DisplayName"
Culture="Culture"
LicenseAgreement="license.txt"
>
<PackageFiles>
<PackageFile Name="license.txt"/>
</PackageFiles>
<!-- Defines a localizable string table for error messages and url's -->
<Strings>
<String Name="DisplayName">Microsoft Access database engine 2010 (x86, x64)</String>
<String Name="Culture">en</String>
<String Name="DotNetFxRequired">Installation of Microsoft Access database engine 2010 requires Microsoft .NET Framework 2.0. Contact your application vendor.</String>
<String Name="InvalidPlatformWin9x">Installation of Microsoft Access database engine 2010 is not supported on Windows 95. Contact your application vendor.</String>
<String Name="InvalidPlatformWinNT">Installation of Microsoft Access database engine 2010 is not supported on Windows NT 4.0. Contact your application vendor.</String>
<String Name="GeneralFailure">A fatal error occurred during the installation of Microsoft Access database engine 2010.</String>
<String Name="AdminRequired">You do not have the permissions required to install this application. Please contact your administrator.</String>
</Strings>
</Package>
license.txt
For detail please Log on http://www.microsoft.com/en-us/download/details.aspx?id=13255
Note: I've already tested in my Windows 7 x86 Machine and it works perfect. It doesn't reinstall if already installed. I've no x64 machine so I don't know the Product code of it. But I'm sure it'll work too. It also downloads this package from website and I've tested that.
If you need any further help or complete Bootstrapper Package just let me know.
Cheers.
You migth be able to use
Microsoft Access Database Engine 2010 Redistributable
-- Update --
To add custom prerequisites you need to create a Bootstrapper Package here are some instructions:
Creating Bootstrapper Packages
Deploying Custom made Visual Studio prerequisites using Bootstrapper Manifest Generator
-- Update 2 --
For 64-bit implementations see comment from Massood Khaari below.

WiX installer does not work on vs 2012

I want to create a setup installer for my application. I have downloaded WiX 3.6 and installed it on vs 2012.
Create simple winform application
Add WiX setup project to my solution
Right click on reference and add my winform application to setup's reference
I build solution and go to debug directory in setup project and run SetupProject1.exe.msi it does not work and closes the installer dialog without any error.
Go back to setup project
Right click on setup project and select properties
On installer tab > output type, change it to executablefile.exe
Build it and go to debug and run SetupProject1.exe - still does not work
What is wrong? This is my setup project product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="Natiloos" UpgradeCode="cfc2f4dd-2da5-49e2-9099-96968d75aaa4">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
How can I get the installer to build correctly?
The problem is your installer is not installing anything. Adding your project as a reference to the installer does not mean the installer will include your projects output. In your setup project you have:
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
You need to add the files...i.e. uncomment the <Component></Component> tags and add your files manually. It's good to have one <Component> tag per file.
Example:
<Component Id="MyProgram.exe" Guid="PUT-GUID-HERE">
<File Id="MyProgram.exe" KeyPath="yes" Source="Path_To_Output_Folder\MyProgram.exe" />
</Component>
WiX projects of the type that you are describing produce MSI files, with the .msi extension. These installers are not run directly, rather then are run using msiexec.exe. Windows explorer does this for you by default when you double click on them, however you can explicitly call msiexec using a command like the following
msiexec MyInstaller.msi
Note that MSI files are completely different from executables - changing the output name of your setup produce to have an .exe extension, or renaming the file to have an .exe extension won't work.
If you want to produce an .exe based installer then what you need is a bootstrapper. WiX has one called Burn, however if I were you I would worry about making an MSI that works first and then worry about creating an executable bootstrapper.

Categories