Top

Fixing .NET Installers

August 28, 2008

Another ridiculous failure on the part of Microsoft to understand how small developers need their tools to work.

You’ve finished your .NET project and are ready to distribute. Visual Studio has spit out two files for you: a setup.exe which makes sure the user has the requirements (the targetted version of .NET, as well as Windows Installer), and a .msi file containing your product.

So what happens if your user doesn’t have .NET?  Well, setup.exe fetches it, and installs it (in a process that can take an are-you-freaking-serious 20 minutes) and then, more likely than not, reboots.

This is not a big deal if you don’t mind making your users download either both of these files, or a zip file containing the two.  But if you want to make the install process as easy as possible, you would like to have a single installer that handles all of that.  But Visual Studio, for some unknown reason, doesn’t handle this very basic requirement.

What we need is something that does the following: unpack setup.exe and YourApp.msi to a temp directory and launch setup.  But what happens after the reboot?  It is crucial that both files still exist, or you’re doomed.  Installation will fail.

There are a couple options people might suggest –  iexpress is one of them.  Skip it.  iexpress isn’t going to work here.  For whatever reason, iexpress creates an installer that deletes its temp directory as soon as setup.exe is launched.  Consequently, YourApp.msi is missing when setup.exe launches it.  Not persistent enough.

I found other, free programs that almost do what we need.  I won’t name them here, because they don’t work.  The best of the bunch deletes the temp directory on the next reboot, but that doesn’t work because the .NET installation requires a reboot before your app is installed.  Again, this results in a missing .msi and a failed install.

So here’s the solution: download NSIS.   This is the Nullsoft installer you may have used in the past.   We need to build a simple script, stick it in the same directory as setup.exe and our .msi file, and compile it.  The output will be a new .exe which unpacks our two files to a temp directory, launches setup.exe, and keeps all of our files around as long as we need them.

Here’s the script:

  1. # define the name of the installer
  2. outfile "MyApp_Setup.exe"
  3. SilentInstall silent
  4.  
  5. # define the directory to install to, the desktop in this case as specified  
  6. # by the predefined $TEMP variable
  7. installDir $TEMP\MyApp
  8.  
  9. # default section
  10. section
  11.  
  12. # define the output path for this file
  13. setOutPath $INSTDIR
  14.  
  15. # define what to install and place it in the output path
  16. file setup.exe
  17. file "MyApp Setup.msi"
  18.  
  19. Exec "$INSTDIR\setup.exe"
  20. sectionEnd

Comments

Got something to say?

You must be logged in to post a comment.

Bottom