Wrap C# application in .msi installer - c#

I have created a C# application in Visual Studio 2017. Now I would like to distribute my application as a single windows installer file.
I was hoping for a simple one-click solution (select all the files I want to include -> voila! there's the installer). But it seems to be not that easy :-(
I often read that Visual Studio supports setup projects. But that does not seem to be the case anymore, right?
Third party tools are either very complicated (e.g. Wix, Inno Setup) or very expensive (e.g. Advanced Installer).
Is there really no simple way to wrap some files in an .msi Windows installer?
Does Microsoft provide no tooling to create such installers?

At one point, Microsoft did remove the "Visual Studio Installer Project" support from Visual Studio1. And then they later relented and added support back. I can't remember which versions didn't have support, I think it was 2012 and 2013.
These days (for VS2017), to get the Visual Studio Installer Project support, you add it from the marketplace:
This extension provides the same functionality that currently exists in Visual Studio 2015 for Visual Studio Installer projects. To use this extension, you can either open the Extensions and Updates dialog, select the online node, and search for "Visual Studio Installer Projects Extension," or you can download directly from this page.
Personally, however, I'd go with WIX. It does have a learning curve but I think it's learning worth doing.
1For what I personally see as very good reasons. You had to have a full-blown install of Visual Studio to make them work, they didn't really integrate with MSBuild, which makes them a pain if/when you want to move to automating your builds.

VS Installer Projects: Several good answers already - worth trying out. As stated by others you can use Microsoft Visual Studio 2017 Installer Projects - as limited as they are (bullet list form). They feature some pre-requisite functionality as I recall. I have limited experience with the tool. Could work for something very simple, but you will quickly discover limitations.
WiX: Personally I would use WiX since it is also free and flexible - it takes some effort, but is very capable. Here is a WiX quick start tip answer (frankly not my favorite answer, but it has been upvoted more than usual and updated frequently - hopefully it still has its essence of helpfulness).
IsWiX: There is also IsWix - a GUI tool to help create WiX setups (Chris Painter's work). His WiX tutorials and a quick youtube demo.
Et Al: The commercial tools (Installshield, Advanced Installer (see Bogdan's answer in this "thread"), PACE Suite, etc...) are also good - your time costs too. Can be shocking once you add it up - and you will definitely get running quicker with a commercial tool. How to create windows installer (links to pretty comprehensive lists of tools and some MSI information). Further links below.
Other than that, I'll just link to a few pre-existing answers with info about various tools:
Quick review of different MSI tools
What installation product to use? InstallShield, WiX, Wise, Advanced Installer, etc

or very expensive (e.g. Advanced Installer).
There is a also a free edition which includes a Visual Studio extension for Advanced Installer, which you can use to build MSI packages.
The following tutorial shows how you can use the features from the free edition ("Simple" project type):
https://www.advancedinstaller.com/user-guide/tutorial-ai-ext-vs.html
https://www.advancedinstaller.com/user-guide/tutorial-simple.html
P.S. I work on the team building Advanced Installer.

Related

Is it possible to modify the UI of an MSI created with Microsoft Visual Studio Installer Projects?

I have created a setup project with Microsoft Visual Studio Installer Projects, everything works fine, registry keys, post build event etc .. but is it possible to modify the UI of the installer? for example add a background image, change the font of the characters?
The UI of the current setup look like this
Visual Studio installer project is a limited tool that may not provide this sort of customization capabilities. Some properties should be supported, though, through the "Properties" panel of your installer in Visual Studio.
You can also edit the generated installer, there are tools to edit MSI files directly (like InstEdit or Orca for example). But this is quite time consuming, and probably more suitable for one-time job and not for a continious development process.
If you want to customize your installer to the maximum extent possible for MSI format, you better pick some other tool for creating MSI, like WiX Toolset for example or Advanced Installer. Alternatively, if you are okay with .EXE installer and don't necessarily need MSI, you can also pick NSIS or Inno Setup for example (looking at the category of free tools). Something like that could spare you some time you would otherwise spend on learning the internals of the MSI.
I am not familiar with the VS installer project. But I can recommend the Wix Toolset .. it is extremely flexible.. sometimes too much), but there you can build you r own screens quite easily.

How can I create an installer for a WPF application as well as a ASP.net application?

I have a Visual Studio 2017 project that contains a WPF application and a ASP.net application that interact through a database.
I am currently using this to create an installer for the entire project.
The problem I'm having is that I can successfully create an installer for the WPF application, but not the ASP.net application. Is there a way I can create an installer that installs both applications on a separate computer?
Thanks
Usually, you have to choose a tool or set of tools to generate an installer for your projects to be deployed in your users'/consumers' computers. There are lots of available options. Some are free, some are paid (and quite expensive).
Free ones include WiX Toolset and InstallForge. Paid ones tend to be a lot easier to use and offer more ready-to-use features, and examples of these are InstallShield and Advanced Installer.
I personally use WiX, as it offers quite interesting features, it is free, and has a huge comunity. On the other hand, its learning curve can be quite steep, depending on your specific needs.
Many other options are available. For a simpler (although much less flexible) solution for WinForms and WPF projects, check out ClickOnce.
Maybe you can try Inno Setup: http://www.jrsoftware.org/isinfo.php

Additional Setup in Visual Studio Installer Projects

I am trying to create an installation for my project. I am using MS Access DataBase and for it to work Access DataBase Engine is required. If i download that engine https://www.microsoft.com/en-us/download/details.aspx?id=54920 from here and install it, program works.
How can i add that installation to my installation?
I am using Visual Studio 2015, C# and OLEDb.
Short Version: In essence you will need a deployment tool. List view of major deployment tools. Maybe that list view is the easiest overview? (a sense of scope). Much more detail below (and too many links too).
Details: There is some prerequisite functionality available in Microsoft Visual Studio 2017 Installer Projects, but I am unfamiliar with the details. I find this project type inadequate for real deployment work for a lot of reasons (lacking features and some odd implementations). More on this here - a few concrete problems to consider.
Several commercial tools will do this for you with special features to help make it quick(er). I verified that Advanced Installer can do it (and here is a great gateway to all things Advanced Installer. Some free features available). I assume Installshield can do it as well (certainly for other runtimes, didn't verify this particular one). Generally it will be handled by a setup.exe bootstrapper / chainer embedding all runtimes along with your own MSI file(s).
In other tools, you will have to do it yourself, by figuring out command lines and how to handle error conditions. There are some hints here (not tested by me - a google sweep will give you more): https://www.itninja.com/software/microsoft/access-runtime/2016-1
Get more command line info by going accessruntime_4288-1001_x64_en-us.exe /?:
WiX is free and open source - with a relatively hefty learning curve if you don't know MSI, and contains a bootstrapper feature called "Burn". Here is the documentation for: How To: Install the .NET Framework Using Burn (first read the "Building Installation Package Bundles" instructions in "Step 1"). A real-world Burn sample. And some sample source markup.
Some developers recommend the dotnetinstaller bootstrapper. Not something I know much about. It is just a bootstrapper. Runs things in sequence for you.
If you are doing in-house or ad-hoc deployment, even a batch file could do the job I suppose, but if you do that for a real product for large-scale and generalized deployment I would be very worried indeed. If there is one thing we hate as deployment specialists, I'd say it is batch files embedded in packages. Batch files (and scripts) are system administrator tools, not general deployment tools.
Some Older Links:
Executable files to MSI installer
How do Installation Software Programs Extract Files?
Create MSI or setup project with Visual Studio 2012
How to make an installer that automatically install all the prerequisite programs for the application
Windows service NOT shown in add remove programs under control panel
How to make an installer that automatically install all the prerequisite programs for the application
Wix - How to run/install application without UI
Visual Studio setup projects have a Prerequisites choice in the project's properties. This allows you to choose from a list of standard prerequisites and generate a setup.exe that will install the prerequisites and then install your MSI. The Access Runtime doesn't appear in later versions of setup projects because (I assume) Access 2013 ended mainstream support in 2018. The way to add your own prerequisites to this mechanism was with the Bootstrap Manifest Generator, which is perhaps still available but not well documented:
https://msdn.microsoft.com/en-us/library/ms165429.aspx
Apart from that I'd recommend that you learn how to build a WiX Burn bootstrapper executable that will install the Access Runtime and then install your MSI (which you still build with Visual Studio if you need to). If you do a search for that you'll find this kind of thing:
WiX - Install Prerequisites and 3rd party applications
https://www.c-sharpcorner.com/UploadFile/cb88b2/installing-prerequisites-using-wix-bootstrapper-project-and/
These will explain how to build the Xml to check whether the Access Runtime is installed and the command to use to install it. This is a much better choice than the Bootstrap Manifest Generator.

Windows service NOT shown in add remove programs under control panel

I installed my windows service via (name of the service: Testing Service)
InstallUtil.exe present in .NET Framework
(:\Windows\Microsoft.NET\FrameWork64\v4) in a windows 7 computer.
I can see my service under services console.
However, i went to programs and features of control panel to manually uninstall the same service, i didn't see my services under programs and features?
Any thoughts why a service will not be shown, so that, user can
uninstall it?
I checked the show hidden files too, but still service not shown?
InstallUtil.exe: As others have stated, InstallUtil.exe is intended for development use only, not for final distribution of your service.
MSI: The normal way to deploy services in the fashion you describe (with a proper entry in add/remove programs) would be to use an MSI installer created using a tool designed to help you do so (it is not advisable to "roll your own" tool to do this).
Ad-Hoc: The ad-hoc description of deployment tools below was written in a hurry, and has sort of been re-purposed as a general description of
such tools. Not too relevant for the question asked, but it sort of "happened" and here it is.
Free MSI Tools / Viewers
How can I compare the content of two (or more) MSI files? (towards bottom) - (most of) these are not full-featured tools to make setups, but great to inspect MSI files and to create transforms.
MSI Tools: Short-List
There are many tools you can use for MSI-creation, for example (arbitrary order - links to Stefan Kruger's installsite.org below will show further tools, these are just the most common ones):
WiX - quick download
Free, open source framework - excellent, but with a learning curve, hence a few more links.
WiX quick-start tips (a bit chaotic, strangely upvoted, must be helpful).
WiX's commercial branch FireGiant has a WiX expansion pack (which costs money).
Windows Installer and the creation of WiX (what is the idea behind WiX?).
How to install and start a Windows Service using WiX.
Documentation: ServiceInstall, ServiceControl.
Untested: How to create a Windows Service MSI Installer Using WiX.
IsWiX - quick download
Deployment and MSI expert Chris Painter has his own, free WiX-based tool called IsWiX
It can help with WiX's learning curve and manage WiX source files.
Also see his IsWiX Tutorials.
The various ways used (and abused) to install Windows Services.
Advanced Installer - quick download
Great commercial tool with lots of smarts to help you deliver packages quickly and reliably.
Some free features.
Here is a great gateway to all things Advanced Installer.
installing services, how-to.
InstallShield - quick download
The old and established market leader tool Installshield features a very rich set of functionality capable of delivering advanced setup requirements.
There used to be a Lite version which cost money at one point. Not sure if it is available now.
There is an InstallShield Limited Edition version. Unsure of its feature set and cost (if any). Does not work with Visual Studio Community editions.
Installing, Controlling, and Configuring Windows Services.
PACE suite - quick download
https://pacesuite.com/support/
https://pacesuite.com/docs/v5.5/how-to/edit-mgp/services/index.html
Visual Studio Installer project type
There is also the Visual Studio Installer project type in Visual Studio (VS 2017 sample).
I would not really recommend this - especially if you have advanced deployment or automation requirements.
It is very basic, and there are many severe limitations.
Install the Visual Studio setup and deployment project template.
Auto-Update?: Various ways to create auto-updating packages.
MSI Tools: Comparisons and Descriptions
What are the above tools like in actual use? Here are some pragmatic observations and summaries:
How to create windows installer (recommended overview).
What installation product to use? InstallShield, WiX, Wise, Advanced Installer, etc (an aging, detailed comparison of these major MSI tools - very detailed and "pragmatic").
Deployment Tools (General)
There are many further tools available to create create installers / setup.exe files of various kinds (not just MSI tools, but general purpose, legacy tools, multi-platform tools, etc...):
Stefan Kruger's Comprehensive Lists:
Non-MSI installer tools: http://www.installsite.org/pages/en/tt_nonmsi.htm
Windows installer tools: http://www.installsite.org/pages/en/msi/authoring.htm
Sys-admin tools: http://www.installsite.org/pages/en/msi/admins.htm
Other Links:
Cross-Platform Installers: Does an universal cross-platform installer exists? (non-MSI tools).
dotNetInstaller: There is also the dotNetInstaller Setup Bootstrapper - which I have never used.
Here it is on github.com (source).
Just a bootstrapper (runs things in sequence for you, and then some), not a development tool as such. I find this tool "a bit weird".
Some General Links: And there are various other ways to deploy - for example with self-extracting zip archives and stuff like that. Not recommended, but some links:
Error Creating a 7-zip installer package (7-Zip, iExpress and other self-extractor creators)
Combine exe and msi file in one installer (recommended)
Visual Studio 2017 Installer Project - include VC++ 2015 Redistributable (WiX Burn Quick Start)
Additional Setup in Visual Studio Installer Projects
InstallUtil only performs actions exposed by your .Net Installer classes, such as registering a service.
It does not perform the "standard" application installation which results in the entries being added into add/remove programs.
To do this, you will need to look at various install builders such as Wix, Installshield, etc.
Installutil.exe (Installer Tool)
The Installer tool is a command-line utility that allows you to
install and uninstall server resources by executing the installer
components in specified assemblies.
Its job in life is to do exactly that,
To fill in your knowledge you should read through this
Chapter 2. Install/Uninstall
You will notice this is an entirely different concept, and actually has all the information you need (albeit in a very verbose manner)
There are various ways to achieve what you are after, one of them is using out of the box installation software, MSI, click once, or many others. or you could roll your own by using the above resources
There is a Microsoft Visual Studio 2017 Installer available via Tools->Extensions and Updates
This official Microsoft Extension provides support for Visual Studio Installer Projects in VS2017
Because I cannot make and edit the most interesting answer, I will add it here:
NSIS Installer - quick download
NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers. It is designed to be as small and flexible as possible and is therefore very suitable for internet distribution.
Free and open source
Used by WireShark (source of Wireshark installer)
Example tutorials

How to create an installer and uninstaller for a Windows Forms application

I created an installer for my Windows Forms application and I added the project output to programs menu. But now what I want is 'I should have a folder in programs menu in that it should contain both install and uninstall options'.
Please help me. Thanks in advance.
The easiest way is to create a Setup and Deployment project in Visual Studio.
I have to agree with Sir Richard's answer, but I wanted to add the instructions on how add an uninstaller using the Setup and Deployment project found in Visual Studio.
Here's a useful link you can work on: How to add a Uninstall option in Visual Studio Setup project without writing code
If you have advanced scenarios that the Setup and Deployment project can't handle, I'd advise looking into WiX.
WiX is an extremely mature Microsoft opensource project, having first launched in 2004 and is still active today. It even provides a VS extension to assist you with getting started and intellisense for the configuration.
Be warned though: WiX primarily uses XML files that use MSI's domain language. It's certainly not a tool you use if "create an installer" wasn't allocated specifically in your project plan.
You can try with NSIS, is open source and very easy...
"NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers. It is designed to be as small and flexible as possible and is therefore very suitable for internet distribution."
in his website you can find tutorials and examples, the link is: http://nsis.sourceforge.net/Main_Page
I hope this help you!

Categories

Resources