How to Build WPF project with Setup file (Installer Project)
Firstly create a WPF project say "SampleWpfApplication". Here I'm going to use Visual Studio 2013.
You can add your necessary runtime projects' library dll into your project reference if you want. Here I included a sample runtime project's library into my project.
By default in your visual studio you will not see "Visual Studio Installer". If you don't see then you have to download it from visual studio installer project for 2013 and install it.
So next You have to create Setup project.
Your project is added into your solution.
Go to view File System of the installer project.
Then you'll see
1# Firstly you have to add project output into "Application Folder"
If you have multiple projects into your solution then you have to select your Startup Project (UI Project) from project list.
Here you'll see your referenced library's dll is included autometically. If you need to include any dll externally then you can add here using "File" option. Below later I'll add "logo.png" file as shortcut icon using "File".
2# Next you have to create a folder under "Program Files Folder" and name it by your software name. Here I am naming it by "Sample App".
After that you have to add again Project Output here as we did earlier for "Application Folder" section.
Here no dll file will be added
Now we are going to create Desktop Shortcut and Program's Shortcut.
Right click on the created Project Output file into "Sample App" folder under "Program Files Folder" and you will see create shortcut option there.
Then rename it with your software name.
After that cut that shortcut file and paste it into "User's Desktop"
Follow the same approach to create shortcut for user's programs menu and paste the shortcut file into "User's Programs Menu" folder.
Select Setup project and then go to Properties window to set your software information.
Here right side you can see the properties window. Set your necessary information there.
Here at the bottom you will see version. Suppose you are going to install your software and that computer has already installed a copy of this application. In that case, if your current created installer has version number higher that installed one then while installing current one will automatically replace the previous installed one.
Another important point is you have to make each folder's "Always create" property "True". Example is given below.
Now I'm going to show about including icon for created Shortcut. I am using 48x48 sized .ico image file.
1# First include the file into "Sample App" of "Program Files Folder".
2# After that go to "User's Desktop" and select the shortcut file and go to its properties window. There you'll find Icon option.
Select browse option
Icon is set now.
Do the same procedure for "User's Programs Menu" too.
Now rebuild the Installer project.
Then you will see 2 files into installer project's debug folder.
If you want to rename output msi file name, then right click on the Setup Project and click Properties.
If you want to add .Net version as prerequisite for your software, then go to the properties section of the installer project.
Create Installer Project
Now its time to add our installer project.By default in your visual studio you will not see "Visual Studio Installer". If you don't see then you have to download it from visual studio installer project for 2013 and install it.
So next You have to create Setup project.
Your project is added into your solution.
Modify Installer Project
Go to view File System of the installer project.
Then you'll see
Add "Program Files Folder"
Add Project Output
1# Firstly you have to add project output into "Application Folder"
If you have multiple projects into your solution then you have to select your Startup Project (UI Project) from project list.
Here you'll see your referenced library's dll is included autometically. If you need to include any dll externally then you can add here using "File" option. Below later I'll add "logo.png" file as shortcut icon using "File".
2# Next you have to create a folder under "Program Files Folder" and name it by your software name. Here I am naming it by "Sample App".
After that you have to add again Project Output here as we did earlier for "Application Folder" section.
Here no dll file will be added
Create application shortcut
Now we are going to create Desktop Shortcut and Program's Shortcut.
Desktop Shortcut
Right click on the created Project Output file into "Sample App" folder under "Program Files Folder" and you will see create shortcut option there.
Then rename it with your software name.
After that cut that shortcut file and paste it into "User's Desktop"
User's Programs Menu Shortcut
Follow the same approach to create shortcut for user's programs menu and paste the shortcut file into "User's Programs Menu" folder.
Set Software Information
Select Setup project and then go to Properties window to set your software information.
Here right side you can see the properties window. Set your necessary information there.
Here at the bottom you will see version. Suppose you are going to install your software and that computer has already installed a copy of this application. In that case, if your current created installer has version number higher that installed one then while installing current one will automatically replace the previous installed one.
Another important point is you have to make each folder's "Always create" property "True". Example is given below.
Setting Application Icon for Shortcuts
Now I'm going to show about including icon for created Shortcut. I am using 48x48 sized .ico image file.
1# First include the file into "Sample App" of "Program Files Folder".
2# After that go to "User's Desktop" and select the shortcut file and go to its properties window. There you'll find Icon option.
Select browse option
Icon is set now.
Do the same procedure for "User's Programs Menu" too.
Installer Build
Now rebuild the Installer project.
Then you will see 2 files into installer project's debug folder.
If you want to rename output msi file name, then right click on the Setup Project and click Properties.
Add .Net as Prerequisite
If you want to add .Net version as prerequisite for your software, then go to the properties section of the installer project.
If you want to supply your desired .Net version with your installer then select 2nd option.
Press "OK" and build the project. You may see the following error. If not, then you are done.
If you see this error, then go the link showing in error message.
Go to down of that page you will see link named Download Center. From there download the .Net version.
After download completed go to the following directory
For Visual Studio 2013
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper\Packages
For Visual Studio 2012
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bootstrapper\Packages
Then you have to paste your downloaded .Net file into your preferred "DotNetFX" folder. As I am using .Net4.5 so I paste my downloaded "dotNetFx45_Full_x86_x64.exe" file into "DotNetFX45" folder.
After that rebuild your installer project and you will see "DotNetFX45"(in my case file name is that) into your debug folder.
That's it. You built your installer with your prerequisite .Net :)
Inspired by following link
Comments
Post a Comment