Search code examples
installationsetup-projectsetup-deployment

How can I keep a Setup and Deployment project from replacing the files it creates?


I have a Windows setup and deployment project with which several non-essential files are created. When those files are deleted by the user, the program re-creates them when it's run the next time.

How can I prevent this behavior?


Solution

  • There's no support for this in Visual Studio setups, but the documented way to do this is to have a null Component Id for the files that will be deleted:

    https://msdn.microsoft.com/en-us/library/aa368007(v=vs.85).aspx

    and see the ComponentId description. So you'd need to edit the MSI file with Orca or a similar tool and set the Ids to null for the files. This can be automated with a post-build script with some MSI SQL and a VBScript or program.

    Attempts to make this go away by trying to disable the repair generally fail because not all repairs can be prevented (such as right-click the MSI and repair, or perhaps Programs&Features) and an upgrade (RemovePreviousVersions) may well result in them being re-installed so that Windows can see if they need to be updated or not (which it cannot do if they are absent).