how to change c# built in event behavior - c#

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.

Related

Merge Multiple (setup) Files into Single Setup

I have a project (Outlook desktop add-in) in the following stack:
C#
Dot net pre-requisite 4.5.2+
When I build the application, I get a setup folder of 3 files/folders:
setup.exe
project-vsto.vsto
Application Files - folder with dll.deploy and manifest files
When I run this exe manually, I can see the installation in my control panel and things work fine.
Now, for mass deployment purposes, I package this folder using advanced installer, through which I create a packaged msi of the project.
On manual installation of this msi, it does 2 things:
"Installs" the packaged project. It can be seen in the control panel. However, this is not the actual thing, more like extraction of files in "C:\program-files..." and we need to run the "setup.exe" here.
Runs the setup.exe, as it is mentioned in the exit dialog at the time of msi creation. This is actual project installation step.
However, when I deploy this through SCCM or GFI (Languard) (which we will be using for mass deployment), second step does not follow. What is the work-around through this?
Is there any thing in advanced installer which I can do to omit step-1? I have read docs etc but could not find other than doing this through custom actions or exit dialog (I've tried both, obvs) which behave in same way as far as my situation is concerned.
Or,
Can I tweak some setting in SCCM or GFI (maybe add custom action there, or some installation switch, or some other setting?!!) which can help me achieve my purpose.
Any leads which can help my cause will be greatly appreciated. Thanks in advance.
Most likely you didn't use the built-in support Advanced Installer has for Office addins.
Here it is a video tutorial about how to create a setup package for an Office Addin with Advanced Installer:
Package Office addin with Advanced Installer
Try to follow these steps and check the outcome.

Application Installer: Microsoft database engine 2010 not available under pre-requisites

I have a windows form c-sharp application developed for windows 10. When I am trying to make installer, I cannot find "microsoft database engine 2010" (important for my app) under the "prerequisite" as shown below:
I do not want my customer to separately download it and install it. So is there a way I can generate an installer that will install complete software along with microsoft database engine 2010 ( if it is not already installed on the system) ?
I have never used this runtime, but did you do a Google search? It looks like the runtime is available: https://www.microsoft.com/en-us/download/details.aspx?id=13255. I am sure you did. Perhaps it is the wrong one? Or a format you can't use I guess.
The downloads are x86 and 64-bit versions in EXE format. The EXE files have embedded MSI files (Windows Installer) that you can extract, or you should be able to just run the EXE in silent mode (probably safest). Do a AccessDatabaseEngine_X64.exe /? to get a list of parameters.
Merge Modules
Normally you can use a merge module to add a runtime component to your own MSI at compile time, but this runtime may not be available in this format. Instead you can use a bootstrapper of some kind to run your own MSI installer and this prerequisite database engine runtime MSI / EXE in sequence (or even just a batch file - see towards the bottom).
Bootstrappers
The WiX toolkit (which is a better way to make MSI files than Visual Studio Installer Projects - see the link for some details) features a bootstrapper called Burn - it can install both EXE and MSI files in sequence. There are also other bootstrappers available, but I haven't tried them. Here is a description of some bootstrappers from earlier: Wix - How to run/install application without UI.
As you will see in the link immediately above, there is a sample of the WiX bootstrapper Burn in use here: https://github.com/frederiksen/Classic-WiX-Burn-Theme (it even shows a WiX MSI package as well). WiX and Burn does have a learning curve.
There may be simpler options available using Visual Studio Installer Projects that I am not aware of, but I think you need a bootstrapper to install several MSI files in sequence. As far as I can see these Installer Projects support only the listed prerequisites that you show in your screenshot to download and install on demand, and they seem to allow the addition of (any) standard merge module. It is very strange that you can't tell the Installer Project's setup.exe to kick off the install of any MSI as a prerequisite considering that the whole feature is made to install prerequisites in the first place. PhilDW will surely be able to tell you with certainty.
Commercial tools such as Advanced Installer or Installshield also have features to allow you to bundle setups, in various formats, together for installation in sequence. It might be a feature in the Premium or most expensive edition in Installshield's case. Not sure for Advanced Installer. Bogdan Mitrache will be able to tell us - they may do it better. I don't want to claim something I am not sure of - things like these change as new versions are released (may obviously also be the case for Installshield).
Batch File, PowerShell Script
In closing I should add that you can obviously use a batch file to install files in sequence (or a PowerShell script - which would depend on .NET though). For example wrapped in a self-extracting archive. You can quickly try the built in iexpress.exe self-extracting tool in Windows: Hold down Windows Key and tap R, enter iexpress and press Enter. Click through the options. Be very aware of the security vulnerabilities iexpress suffers from!
Not sure how well well these wrappers clean up their temporary files (particularly if there are errors during installation) - which could be ugly and annoying, but it should work. A bootstrapper can do a lot more though - such as provide a real GUI for your users and handle error conditions among other things.
Security problems with deployment solutions is a pet peeve of mine, so I want to add a link to this: Prevent DLL Hijacking Burn with Clean Room. A WiX Burn issue fixed in the latest version of WiX (as of Jan.2018). As you can see, the allure and simplicity of iexpress.exe generally does not make up for its security shortcomings. It is most definitely not good enough for a world-wide, large-scale, public release.
Should you want to use a batch file or PowerShell for the installation, then the following answer provides some information on using the msiexec.exe command line, and there is also a link to another answer which deals with PowerShell installation: How can I use powershell to run through an installer?

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

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.

How to create an executable to update a DLL in an installed application

I am looking at making an application more modular and accessing dlls so that I can change them if the client was wanting different functionality.
I know how to create the dlls and reference them, but I am trying to find a way to create an executable that will install a different version of a dll into the required application folder. I want to avoid having to put the new dlls into the original project and build a new install file and I want to keep things simple for the end user.
Currently I am using visual studio 2010
You could create MSI files for each of your dlls and use the standard installer process to update the dll. It is also possible to write an exe that downloads and extracts which will have an arbitrary amount of logic (licensing, download location now and then...).
A combnation of both might seem an interesting thing. A bootstrapper downloading msi files and silently installing them. You could have advanced features in the installer while having the freedom to decide what and when to install on your own.
Technical aspects popping into my mind: files in use may not be changed and if you change the interface theunchanges main program won't be able to use the new library.
It seems you're searching for a plugin architechtecture, you might want to look at MEF or Unity to perform the compositiom, but that is more a side comment.
There are few SO thread available on this great website. You should explorer them and try the best way to implement whatever situation you have..
Check these reference links:
from: Creating a patch to upgrade .NET application
If you already use a a VS Setup Project you can deploy the new version
of this project and it will upgrade existing installations. Have a
look at the setup and upgrade ids. The stop and start of the service
can be done by custom actions that can be defined in the project and
will be executed i.e. when your setup is committed or rollbacked etc.
Patch development in DotNet
How to make Patch-able/Update-able application?
create patch file using .net windows application
Note: Ref this For clickonce how to build a patch for existing installer

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.

Categories

Resources