C# Installer Intro:
This is a more complete list of all of the different processes you might want to have in an installer for c# in visual studio 2017. I have collected this data from across several different people on the internet but there seems to be no complete list anywhere so here you go. First thing is that if you want a free installer, what you have to do is to look for something called setup project. Here is a link to the download. https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.MicrosoftVisualStudio2017InstallerProjects
Step By Step Guide
initial setup
#1: Make sure that the download is installed. Simply double click on the download
#2: Open Visual Studio and open the solution that you want to add an installer to. Then right click on the solution itself within your solution explorer, then Add, then New Project. A frame will pop up called Add New Project. From here I recommend Setup Project. Though you could use the Wizard, you will learn more just doing each part on your own. Make sure you name it before pressing OK. It is now a good idea to open the properties of the setup project and change the author and manufacturer. This affects the folder names that it will be stored in.
Get your files to load
#3: Now you should have a screen that says File System come up. If not, don’t worry all you have to do is right click on your newly created setup project, go to view and then File System. From here you can access the different things you might want to modify when your installer runs. Application Folder represents the actual folder that will be created and filled with your source files. the other two are fairly self explanatory as the users desktop and programs menu.
#4: Now you need to choose what files you want to add to your installer. Right click on application folder and Add. From here you have three options. Folder, project output, file, or assembly. Project output is a good option because it auto-detects what is in your C# code and finds a way to insert what is need into your installer. If, however, you have additional files that you wish to add, you can choose either folder, or files. These will come in handy later.
#5: As for the Desktop and programs menu. If you want you can add a shortcut to either of these. If your program is an exe file and it needs to be run then this is a good option.
Setting up the files that you have
#6: It is wise to set up any dlls or other assemblies to be in the proper format. In my particular case I was using COM dlls and so i had to make sure that they were registered correctly. In order to do this I set the Register to vsdrfCOM. I was unable to figure out exactly how to get registry to work for these direct from the installer. As a result I was forced to build a program to do it for me and add it as part of the installation. Update to come If I do figure it out.
Adding an executable to the installation process
#7: You may, as I did, wish to add an executable to your installation process. It is not to hard to do so. First, right click on your setup project in the solution explorer. Go to view, then custom actions. From here you can choose an executable to be an element of your install.
For each of the four folders you are going to right click and then choose add custom action. Here is where the file or folder options from step #4 will come in handy. You can only select an executable from the files you are installing which should make sense because you cant be sure that file will be located in your destination. Select the file you wish to use from the application folder. Next, open the properties for the newly created custom action. Change the Installer class field to false. Once this is done your executable will perform the desired program on install.
In order to make sure that the the installer will overwrite older versions of the installed program. and so follow these steps to make sure that it installs properly.
- Set Remove Previous Installation as True
- Set Detect new version as True
- Your C# program’s version must increase with every deployment
- You should change version of your installer to one higher version and it will ask you to change product code, select YES.
- Do not change your upgrade code, let it be same.
https://stackoverflow.com/questions/3024753/installing-a-new-version-of-a-deployment-project-over-old-version
Conclusion
At this point your installer should build your C# program on a new windows platform.