Basic Walkthrough for creating an MSI Installation package in Visual Studio 2008.
- Open the project for which an MSI Installation package is to be added in Visual Studio 2008.
- Right click the Solution of the Project in the Solution Explorer and select Add->New Project from the context menu.
- Expand the 'Other Project Types' category and choose 'Setup Project' from the 'Setup and Deployment category'. Enter a name and location for the MSI package to be created and click OK.
- A Setup project will be added to the project solution. Right Click the Setup Project in the Solution Explorer and select View->File System from the context menu.
- Right click 'Application Folder' in the new window and select Add->Project Output. Now, select 'Primary Output' from the dialog box that pops up and click OK. A 'Primary Output from xxx' entry should appear in the Application Folder. This is the main executable of the project.
- Right click the 'Primary Output from xxx' entry and select 'Create Shortcut to Primary Output from xxx'. Repeat this step one more time to create two shortcuts.
- Cut one of the shortcuts and paste it in the User's Desktop folder. Similarly cut the other shortcut and paste it in the User's Program Menu folder. Rename each of these shortcuts to something more appropriate (such as the application name).
- Browse to the MSI project folder (using Windows Explorer), right click and select New->Shortcut from the context menu. In the Create Shortcut Wizard dialog that pops up type '%windir%\system32\msiexec.exe -x {prodCode} ' as the location of the shortcut, where prodCode is the Product Code of the MSI package. This Product Code can be identified from the Project Properties of the MSI Project in Visual Studio. Also, provide a proper name for the shortcut (such as Uninstall xxx, where xxx is the name of the application) and click Finish.
- The next step involves adding this shortcut to the User's Programs Menu folder of the MSI project in Visual Studio. The problem is that files with extension .lnk (extension of the shortcut) cannot be added to the Project. So, first we need to rename the shortcut extension from .lnk to .txt. Open up a DOS command window and browse to the location of the shortcut using the 'cd' command. Now type 'ren xxx.lnk xxx.txt' where xxx is the name of the shortcut item.
- Now, simply drag the renamed shortcut into the User's Programs Menu folder of the MSI project.
- Rename the shortcut from .txt back to .lnk.
- Build the MSI project and the necessary setup files will be created in the bin folder of the project.
13 comments:
Thanks a lot, works like a charm. In your instructions, just include one more step to rename 'xxx.txt' back to 'xxx.lnk' within Visual Studio before building the MSI.
Also, I was wondering is there any way we could do this in some generic way from within Visual Studio itself? Would be great if we could somehow add a custom generic shortcut that pulls the [ProductCode] property within the installer, this way you wouldn't need to manually create the Uninstall shortcut for each product. I couldn't find any way to do this, didn't know if you might know of any other tricks.
Thanks again!
Thanks for reminding me to add the step for renaming the shortcut from .txt back to .lnk in the MSI Project. I'm afraid, I don't know of any generic way by which you can create the Uninstall Program shortcut for multiple MSI projects. Microsoft makes it pretty hard for us to this
Thanks. This is exactly what I was looking for. There are other ways to do it using batch file but I liked this way.
Hi
Thanks a lot for this guide (the uninstaller was bugging me). Perhaps you could also add where the ProductCode can be found:
View the Properties Window when the installer project is selected in the Solution Explorer (and not the Properties menuitem in its context menu, the mistake I made).
Hi, this does not work in Vista and Windows 7. When you click the uninstall link the Start Menu, it says "this option is only available for installed products". I have specified the correct product code though.
Could it have something to do with UAC? Cheers
I'm afraid I don't have access to a Windows 7 or Vista machine...I will try this out on a friend's PC and post the result.
Can i get more clear from the second step i did not find any .lnk file so can you please tell what to do
Hi Dorababu,
lnk is the extension of the shortcut that you create in the first step. Were you able to complete the first step successfully?
Ya i completed my first step successfully but the later i am not getting
Angelo can you tell me what to do form the 2nd process..
At-last i got the required one. Thanks for the article.
Hi Dorababu,
Sorry I couldn't reply earlier. Its great to know that you figured it out. Cheers!!
Thank you so much... You saved me.... Thank you Thank you... :)
Post a Comment