views:

719

answers:

2

I'm using a Setup project in VS 2005, and I've learned all about the "joys" of advertised shortcuts.

My project creates shortcuts to the program on the Desktop and Start Menu, and whenever those are run, the MSI re-installs the application (because installed files have changed). I've also created a file association for my application, which does the same thing.

I've figured out how to set up a vbscript that I can run post-build to disable advertised shortcuts (using DISABLEADVTSHORTCUTS=1), however, I am at a loss trying to figure out how to achieve the same functionality with file associations!

UPDATE: Let me explain what i'm doing and then you can tell me if there's a better way. I'm including a separate utility that my application depends on. I didn't want to add every single file of that utility as a dependency because it really clutters up the setup project, so I zipped it up and just added the zip.

I then run an Installer implementation and overrode OnAfterInstall to unzip the utility into the proper place, then delete the utility zip. It's the deletion of the utility zip that triggers the whole install/repair process when the advertised shortcut is run.

So I guess my solutions are either to A) disable advertised shortcuts and advertised file associations or B) get the MSI installer to not trigger an install/repair on the missing zip file.

+1  A: 

The question is WHY have the installed files changed?

The benefits of MSI repair is that if something gets mucked up, a virus infects your application, or some silly user deletes the wrong files/registry entries then the windows isntaller resiliency check kicks in and repairs all your files.

There are a number situations where the Windows Installer resiliency check will kick in. I'd suggest changing the behaviour of your application so that you don't update installed files. Alternatively if you don't want to conform to "best practices" and not update your installed files then you'll probably need to use an alternate installer technology.

For example, you're not writing changes to stuff in program files are you? How does your application handle running under a limited user account? On a terminal server? On Vista? None of these scenarios will permit writing to the program files folder (or any protected per-machine location)

One solution to prevent this behavior from happening would be:

  • Install default configuration files to All Users\Application Data
  • Copy these on first run to Username\Application Data (aka %AppData%)
  • Only update the per-user files. This prevents configuration being lost/changed during MSI repair.

UPDATE: Try not setting the ZIP as a "key file" in the particular component, I think windows installer only checks for that key files haven't changed. I think you're probably going to run into the limitations of VS2005 setup projects pretty quickly and so it might be worth checking out WiX if you've got the time. Also one thing that you'll find is that Windows Installer setup projects are almost always cluttered, having hundreds or thousands of components seems to be the nature of the beast.

sascha
You make a valid point, but i'd still like to know how to disable advertised file associations.
ZaijiaN
A: 

Try marking the .zip file property Exclude=true in the setup project, this will make the file available to the installer without installing it on the target machine.

That said, I agree with Sascha in that Installer projects often have hundreds of dependencies.

Dour High Arch