Select the properties of the shortcut by right-clicking it and add an icon to it. To create a shortcut to the application, right-click on the Primary output in the middle window pane and select "Create Shortcut to Primary Output", name that shortcut as CreatingInstaller. Right-click the Input folder created and Add file to it, browse for the Sample.txt file in the Windows Application project we created earlier. It is now time to add the Sample.txt file. Add an icon to the form like in the following figure: You can decorate your form to add an icon to it, that icon will also be required at the time of installation to create a shotcut icon to our application. That means the folder will always be created whenever we run the installer, after a fresh build release. Right-click on the folder, select properties and mark Always Create property to True. The folder will be created just below the Application Folder, name that folder Input. So, right-click on the Application Folder in the File system editor and add a folder. Now in this folder creation logic has to be implemented in the out setup project, so that when the application installs, it has all the pre-requisites required to run the application, like the Input folder and the Sample.txt file. Therefore running the application will show two message boxes, one after another showing the text box text and text from the Sample.txt file. Now we also need this Input folder and a Sample.txt file at the time of installation to be located at the location of the installed application.įor file operations I added the namespace System.IO, needless to specify this thou. I chose to keep my txt file at the startup path so that I could explain how to create files and folders at the time of installation. It could also be "bin\release" as per the project build, and specify the file folder name and file name to read the content. Write a few lines of code just to read the txt file from the Startup path, in my case "bin\debug". Therefore just add a text file, I called it Sample.txt to the "bin\debug\Input" folder, Input is the custom folder I created to place my txt file. In the meanwhile let's add some more functionality to our Windows application, let's read a file and show its output in a message box on button click. The Primary output will be added as shown below, having a type defined as Output. Select "CreatingInstaller", in other words the Windows application project name in the "Add Output Project Group" window, select it as the primary output as shown below and click "Ok". Right-click on the Application Folder and add an output project the output project specifies the project we are creating an installer for, like in the following figure: You'll get to see the Application Folder, User's Desktop and User's Program Menu. Now open the file system editor by clicking on the project and select the option to open the file system editor, as shown in the following figure. The project will be added to the solution. Right-click on the solution and add a new project to your solution like in the following figure:Īnd add a Setup Project by "Other Project Types" -> "Setup and Deployment" -> "Visual Studio Installer" as in the following: Now let's create an installer for the same Windows application. I just wanted to write a few lines of code, so I bound the button's click event to show the text box's text: Decorate the control properties as per your prefer. Thus adding a new Windows Form Application in my solution and adding a text box and button to the default form resulted in the figure as shown below. I gave the name CreatingInstaller to my Windows application, obviously you can have your own. The creation of the Windows application is just for the sake of having one to install. There are many alternative ways to do it.įirst let's create a simple one-form Windows application, having a text box and a button only. In this article I would like to explain a step-by-step procedure to create a Windows application and a setup installer for it in a very simple manner, that is easy to understand and follow. And guess what, they were successful in finding bugs in that too. The driving force for me to write this article is my QC team, who accepts the main application to test and verifies my setup installer with their 100% effort. There are numerous articles I found over the network, explaining how to create a setup project, but some do not work as they say, and some do not have a live example to follow. There are many ways provided by Microsoft to create a setup project for Windows applications.īut when I started to create one, I got nothing but queries and confusion of how to start and where to start.
3 Comments
|