How to install pre-requsite software using Visual Studio Installer? - c#

I have pre-requisite software installer, xyz.msi which should be installed via main installer, pqr.msi. I use Visual Studio 2015 installer project to create pqr.msi installer.
I also need to check certain condition like whether xyz.msi is already installed on target machine or not.
I understand that I can add xyz.msi as assembly in pqr installer and set below property to conditionally copy the xyz.msi:
Condition
But, how to invoke the pre-requsite installer to get installed/launched first before main installer silently. Would this cause nested installation and fails? Any other better way?

The condition on the copy that you're referring to is literally just a condition on installing the file to the target system, a plain copy to (say) the Application Folder. It won't install the MSI any more than it will run some exe file you install.
You also cannot install the MSI from a custom action (that would be nested installation failure) so you need a way to install it before your own MSI. There are two choices that I know of:
The bootstrap manifest generator can be used to build a setup.exe that will install your the prerequisite MSI then your MSI. Start here:
https://msdn.microsoft.com/en-us/library/ms165429.aspx
Use WiX to generate a bundle where you mark the prerequistite MSI as a prerequisite for yours. You'd use MsiPackage to install your MSI.
http://wixtoolset.org/documentation/manual/v3/bundle/bundle_author_chain.html
http://wixtoolset.org/documentation/manual/v3/bundle/
Note that you're not building the MSIs with WiX, just the bootstrapper bundle.
If that prerequisite MSI is from a 3rd party then they may have alternative ways to install, such as merge modules you add to your own MSI build.

Related

how to change c# built in event behavior

There is a built event known as BeforeInstall now this event is not firing correctly, it fires when the msi install wizard has begun install and by then it is too late for my pre-requisites to be installed, how do you go about changing the behavior of a built in event or shall i implement my own event with an handler?
It's very badly named. It is not before the install. Everything supplied by Visual Studio where you can run your code is actually run after all the files are installed. That's why you need a prerequisite handler, which is what Visual Studio setups provide with a standard list of prerequisites.
Although the Bootstrap Manifest Generator may still work it's better IMO to use the WiX bootstrapper. Note that you don't need to build your MSI file with WiX but you can use the bootstrapper bundle. Here are some examples and documentation:
http://wixtoolset.org/documentation/manual/v3/bundle/
https://www.firegiant.com/wix/tutorial/net-and-net/bootstrapping/
http://www.c-sharpcorner.com/UploadFile/cb88b2/installing-prerequisites-using-wix-bootstrapper-project-and/
Regarding the later comment about this being related to providing a prerequisite Dll, the simple solution is to add it to your setup project as a file and simply install it in the required folder. All install custom actions in VS setups run after the files are installed. You may be using some "project output" setting as input to your MSI build, but you can just add the Dll as a single file. Some Dlls have redistributable packages (merge modules or executables) to ensure correct installation - if yours is one of those this is the correct way to do it.

Install Shield msi file installing to the wrong directory (error 1309)

I am using Visual Studio 2013/ISLE to create a C# program with a .msi install image. When I run install from VS the program is installed in the expected location, e.g. c:/Program Files (x86)/...
I'm sure that this is something simple but I can't figure it out. A pointers would be greatly appreciated.
When you run a 32-bit installer in x 64-bit system Windows will always redirect your installer writing to c:\Program Files to c:\program files (x86). If you want to install to the non-x86 folder you will need to provide a 64-bit installer for your application.
This blog post explains why Windows does this.
It looks like InstallShield LE will allow you to write to the correct folder when your project is set to AnyCPU, but for more advanced scenario's you'll need to use the Pro version or the free Wix installer.
I assume the question is why the installation MSI fails when you run it outside of Visual Studio, but works when VS launches it?
If yes, you should first check if your ISLE project is creating an MSI or an EXE bootstrapper (that also contains the MSI). If an EXE is created this is what you should launch manually, not the MSI. In theory, a bootstrapper can act like an initialization support for the MSI and specify default values for certain properties, like an installation folder, etc...
I say in theory because I am not very familiar with ISLE, I work with other setup authoring tools, thus cannot say for sure if this stands for ISE projects too.

How do I create an installer that can install dependency software?

Is it possible to create an installer where the user must install 'x' software before continuing with the installer? For example, if the user does not have the required software to use my own software, the installer will guide them through the set up and download the required software and then proceed to install my software as the final step?
I have never created an installer so I have no idea if this is possible.
Is it possible to create an installer where the user must install 'x'
software before continuing with the installer?
Best approach to handle this requirement is to create a Bootstrapper package and add required software as a prerequisite for the main application installer. First you have to install the bootstrapper manifest generater tool from the link i have provided below. Tool will autogenerate necessary manifest files. You have to copy these files to the following folder(Visual Studio2010) C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages.
Once thats done go to your Application deployment project > Properties > Prerequisite There you will see your prerequisite software as one of the prerequisite option. Just select that and create the MSI. Now when you run the Setup.exe of your application it will first check if the prerequisite software package is installed in the target machine if so it will directly install your application otherwise it will first install the prerequisite component and then install your application.
MSDN: The bootstrapper first detects whether any of the prerequisites are already installed. If prerequisites are not
installed, the installation begins for the prerequisites. Otherwise,
if all the prerequisites are detected, the bootstrapper just starts
the application installer.
Creating Bootstrapper Packages
Bootstrapper Manifest Generator
As AccessDenied said, using a bootstrapper is the best option. Right now the best and most powerful free bootstrapper from the industry is available in Wix. It integrates with VS so you can have the setup project directly within your solution, or as a part of your automated build.

how to verify version of files embedded in Windows Installer?

I have built Visual Studio Setup Project, and it contains some Merge Modules etc, now sometimes all dll files included in the project are not showing up as latest version.
After every build, I have to install every setup (5 of them) to check all dlls contain latest version files only.
Is there any API where I can analyze the content of MSI file and verify my dlls have correct version without doing install/uninstall?
Any COM interface will be helpful provided I can program some quick version check on c#.
See the Windows Installer Automation Interface - that should give you what you need.
Also, there are tools out there like Orca or LessMSI, which allow you to peek inside the generated MSI files interactively.

My program has been "published", how can I change the installation path?

I "published" my C# solution in Visual Studio 2008 to C:\Deploy. When I run the setup.exe program, it installs my program to C:\Documents and Settings\Kevin\Start Menu\Programs\MyProgram
Is there any way, within Visual Studio, to set a custom install path? For instance, what if I wanted my program to install to C:\Program Files\MyProgram?
Publishing uses ClickOnce for deployment. ClickOnce has the advantage that it's easy to install and update, and doesn't require the user to have administrator privileges to install your application.
If you'd like a more traditional next-next-next-next-finish installer, which also allows the user to specify the target folder (and for you to set/force a default one), add a "Setup Project" to your solution by clicking File >> Add >> New Project..., in the tree select Other Project Types >> Setup and Deployment and double click Setup Project. When you build the setup project, it create an MSI file (Microsoft Installer setup file) and a bootstrapper EXE file (in case the user doesn't have Microsoft Installer or the required .NET Framework, which it then installs automatically).
ClickOnce ("published") applications are installed per user in the user application cache location. There is no way you can change this location ;-)
You have to use your own setup packaging tool in order to choose or let the user choose the location. Or you can just distribute your application as a zipped executable, if no installation routine has to be called, liked registering file types or adding keys to the registry.

Categories

Resources