This article demonstrates
- How to create a setup package(.msi file).
- How to place the files & folders in appropriate locations in the target machine,.
- Adding registry entry for the project
- Adding Custom File Types
- Adding Splash screen, Read-me screen, Confirm screen, License Agreement etc
- Adding Launch Conditions
- How to check if .NET Framework is installed in client machine and
- Various ways to install CLR(Common Language Runtime) in the client machine.
- How to write formulas to check for
- File existence,
- Registry entries & so on.
How to Create a setup package
In order to create a .msi file using Visual studio .NET
- Open a new project
- Under “Setup & Deployment” project types, select “setup wizard” Template.
- Click “next” until you reach Finish stage.(No need to add any files here as it can be done later)
- Now, you should be able to see two basic screens to work on
- Solution screen
- If not able to see, click view->Solution Explorer
- Project Properties screen
- If not visible, click view->Properties window
How to place the files & folders in appropriate locations in the target machine
After creating the project, you should be able to see the following three folders in it.
- Application Folder
- User’s Desktop
- User’s Programs Menu.
If not visible click View->Editor->File System.
Application Folder is the main target folder where all the files & sub directories for your product will be installed
in the client machine. This location can be mapped to any location in the target machine.
For instance- C:/Program files/Project
To change this location, click “Application Folder” and in it’s properties window set the
“DefaultLocation” attribute to your choice.
Note:- This target folder need not be present in the target machine. If not present, this path you specified will be created automatically.
To your Application Folder you can add Files, Assemblies,sub folders & even other project’s output. In order to create sub folders under your main Application Folder, right click Application Folder,
click Add->Files.
In the same way, all other options could also be added.
For any file added, you can specify conditions. If this condition evaluated to true, only then your file will be placed in the target machine. How to write Conditions is discussed later. Other attributes of file properties window are not discussed as they are self explanatory.
Adding registry entry for the project.
Click View->Registry.
Here, one can add keys, subkeys and to these key string value, Environment string value,Binary value, word values can be added by right clicking on the appropriate Roots.(HKLM/CU/CR/U)
Adding Custom File Types
Custom file types can be added by clicking View->Editor->File Types.
Right click on file types on target machine -> Add file type.
In it’s properties window, enter your own extension in the “Extensions” attribute.
Also, the icon that is to be associated with this file can be chosen in “Icon” attribute”.
In order to associate the file to standard applications like(Notepad,MS-Word etc), click on the new application type & in it’s properties window, for the “command” attribute, browse throught and select the appropriate files.(Eg: C:\Winnt\Notepad.exe”).
Adding Splash screen, Read-me screen, Confirm screen, License Agreement… etc
In order to add these screens, click on the current project & click View->Editor->User Interface.
The rest is self explanatory.
Adding Launch Conditions.
Conditions can be launched before the installation starts such as checking for registry, files, Internet Information Services & so on.
How to check if .NET Framework is installed in client machine
Click View->Editor->Launch Conditions.
Here, right click on “Requirements on Target machine” and select “add .net framework launch condition”.
Disadv: The only condition it checks is the CLR version. If you want to support a range of versions,
Right click “Search Target Machine” and click “add registry search”.
Now, select this condition & in it’s properties window, set Reg key & Root for the key.
Just adding a search condition is not enough & does nothing.
Right click “Launch conditions” and click “Add launch condition”.
For this condition1, in it’s properties window, you can write the required condition.
Eg: If the registry search condition name is “REGISTRYVALUE1”
just write REGISTRYVALUE1 >=v1 or REGISTRYVALUE1 <v1 in condition attribute for condition1.
This means the registry value exists.
To add file conditions,
Right click “Search Target Machine” and click “Add File Search”.
For this new file search’ properties window, enter the file name to be searched in FileName attribute & the folder location in the client machine where the file is to be searched is entered in Folder attribute.
Again just adding a search condition is not enough & does nothing.
Right click “Launch conditions” and click “Add launch condition”.
For this condition2, in it’s properties window, you can write the required condition.
Eg: If the File search condition name is “FILEEXISTS1”
just write FILEEXISTS1>=”0” to check if the file exists.
or REGISTRYVALUE1 <”0” to check if file not exists in condition attribute for condition2.
Ways to install CLR in client machine
- You can specify the URL of either Microsoft or your own portal’ in the InstallURL attribute.
- Or you can place the “dotnetfx.exe” (The main .exe to install CLR) in any server’ accessible folder
and give the complete path including the URL & file name.
The first method automatically opens the web page you specified & user can download “dotnetfx.exe”
The latter one automatically runs the .exe from your server & installs the CLR in client machine.
So, no need to download this .exe(28MB).
Related Posts
- Visual Studio 2010 Great functionality for Developers
- Steps to Create and Deploy SSIS Package as a SQLAgent Job
- Checklist/Guidelines for ASP.Net Developers
- Error: SQL0161N Insert or Update operation does not conform to the view definition
- How to print loggers(log4j) while running Junit Test cases.
Tags: MSI File in Visual Studio DotNet, Setup Package, Setup Package in Visual Studio DotNet





thx a lot!
thanx but i m confused about, what to write in properties window of registry search condition.
regards,
farhan