Sunday, August 23, 2009

Launch executable from MSI created from VS.NET 2008

The project I'm on requires us to use only public domain compatible solutions, so purchasing InstallShield or using open source frameworks was out -- meaning I'm forced to use the built-in VS.NET 2008 Setup and Deployment.

I needed to give the user an option to launch the application after install, and after googling for hours, I never really came up with a good approach for my situation.

That is, until I came upon Aaron Stebner's blog entry. This was exactly what I needed. Note: if that link ever fails, google for "How can I customize an MSI in the Visual Studio setup/deployment project?" and look for the hit on

Essentially, you add a post-build event on your Setup project which calls out to a javascript file that manipulates the MSI. It adds the proper entries into the MSI database.

Here's my post-build event contents:

cscript.exe "$(ProjectDir)EnableLaunchApplication.js" "$(BuiltOuputPath)"

There are no typos in that -- "Ouput" is needed instead of "Output".

If you have one Setup project that includes another, there is one caveat: you need to run the script on both your target dir (bin) and the build dir (obj) since project references pull components from the obj dir and not the bin dir at build time.

1 comment:

Anonymous said...

Remеmber moѕt customeгs prefеr
businеѕs that you bring your οwn ԁevicе.
We intenԁ to sеpaгate ourѕelves frοm
the cοmpetition.

Alsο visit my weblog ... lawyer internet marketing