0

I create my installer with WiX 3.10.3. My installer installs a file (which is optional) to user's home directory (%HOMEDRIVE%%HOMEPATH%). Recently I got this screenshot from a user:

error popup

It shows up as soon as the installer launches and halts the installation. Apparently the user's home directory is H:\, which is a mapped network drive, but disconnected. I simulated same situation and got the same error. So far so good.

If I set intallation path of this file to a folder in a non-existent drive (B:) then I get a different error:

drive error popup

This error is also shown as soon as installer is launched and aborts installation when I click "OK".

If I set it to a non-existent folder in an available drive, then no error is shown. I can complete the installation, the installer creates full path and puts the file there.

Now, I don't have anything in my .wxs file for doing these checks for availability of the drives, so I guess WiX does these checks automatically - but I couldn't find any documentation or text/blog that mentions this behaviour of WiX. and apparently MSI is doing these checks: These error messages correspond to errors 1316 and 1327 in Windows Installer Error Messages list. My problem is that since this file is optional, I don't want these checks to be done for its path.

Even if this particular file cannot be installed I want the installer to skip it and continue. Showing an error screen with "Abort" and "Skip" options during installation would be ideal, but my Google-fu didn't cut it either.

keremispirli
  • 3,283
  • 2
  • 19
  • 26
  • What makes this file "optional"? In general files are either installed or not, and they can be optional in (say) a transitive component or a feature? I ask because this may help us provide a solution. – PhilDW Jan 15 '18 at 23:56
  • It's a config file to make life easier for advanced users, who are currently just us. The application can run in default config without this file. – keremispirli Jan 19 '18 at 09:09

2 Answers2

1

I would suggest creating this optional component to install to a unique directory in a safe location, such as under TARGETDIR, INSTALLDIR, or similar. That is, like the scenario you say works. For purposes of exposition, say you call this directory HOMEDIR, and the component HomeStuff:

: : :
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="HOMEDIR" Name="Whatever">
    <Component Id="HomeStuff" ... />
  </Directory>
</Directory>
: : :

Then, only in the scenario when the component will actually be installed, use a type 35 "Directory" custom action (if after costing; otherwise use a type 51 "Property" custom action) to change HOMEDIR's path to [%HOMEDRIVE][%HOMEPATH].

If you don't require the home directory to exist in order to install the component, then you'll need to test for its existence before you set HOMEDIR to the home directory path. You'll also need a fallback location for that scenario, and to implement that as a fallback somehow. (Preferably make it the original location and just don't update HOMEDIR.)

: : :
<CustomAction Id="SetHomeDir" Directory="HOMEDIR" Value="[%HOMEDRIVE][%HOMEPATH]"/>
: : :
<InstallExecuteSequence>
  : : :
  <!-- Set location if the component is being installed (not reinstalled)
       See Conditional Statement Syntax (https://msdn.microsoft.com/en-us/library/windows/desktop/aa368012) -->
  <Custom Action="SetHomeDir" After="...">$HomeStuff=3 AND ?HomeStuff &lt;&gt; 3</Custom>

  <!-- or, if you test for the home directory's existence -->
  <Custom Action="SetHomeDir" After="TestHomeDir">HOMEDIREXISTS</Custom>
</InstallExecuteSequence>
: : :
Michael Urman
  • 15,737
  • 2
  • 28
  • 44
1

UPDATE: I just discovered that this is an old question, I'll leave in what I have written anyway.


I think this relates to the larger, general issue of "deployment of user profile files" - which has always been problematic as described in this little summary: Create folder and file on Current user profile, from Admin Profile.

Of particular importance is the potential for the Windows 10 ransomware protection feature to cause problems for user-profile deployment of files altogether. Other security software could also interfere.


Suggested Answer

Following from the "discussion" in the link above, can your application create this file on launch instead? Your application can copy it from a template installed somewhere in INSTALLDIR - once for every user of your application. No other deployment issues to worry about.

This should be a much more reliable solution than adding a lot of custom logic to your setup, since your application can perform better checking and exception handling than what is available in an installer and you will be running in a predictable impersonation context and sequence (an MSI installer has complex conditioning, sequencing and impersonation issues to deal with).

Further, the launch sequence of your application is easier to debug and manage overall - it is just one more source file in your familiar development language - and again, no sequencing or impersonation issues - just your familiar development tool and debugger. In my view: a piece of cake for you - the world of installers may be unknown for you, and maybe a nuisance to deal with?


Below are some more generic comments to point out some Windows Installer pitfalls you might want to avoid. The above is the "real suggested, answer".

Deployment's Conspiratory Complexity

Though not the worst field of complexity, installers and deployment feature a "conspiratory complexity" that is not immediately obvious (gotchas that suddenly surface - you can't upgrade properly, uninstall doesn't work, patching fails, settings are overwritten during upgrades, etc...). Deployment is complex when it comes down to it, here is a summary: What is the benefit and real purpose of program installation?. And there are many common problems seen by developers making their first installers: How do I avoid common design flaws in my WiX / MSI deployment solution?

Make Deployment Simpler and Simpler and Simpler and...

Further: IMHO installers should be made "dumber" (just copy files and prepare app for first launch) and your application "smarter" (perform actual application configuration, crucially for each user). The rationale for all this can be found in the link at the top of the answer, but in general MSI installers are too vulnerable due to their unusual complexity and because of the ever present stream of Windows design changes that may make "smart setups" fall over in unpredictable ways.

As a concrete example: MSI files writing directly to the user profile may face runtime errors because of the new ransomware protection feature added in Windows 10 (which protects the user's data folders from writing by "unknown" applications). This protection feature is currently not on by default, but may become a big problem if Microsoft decides to switch it on by default. At that point they may have sorted out these MSI interference issues though. Still, see the linked answer above on user profile deployment for more such "gotcha-issues" that are hard to predict and foresee. Several Windows patches have caused weird deployment problems. Simple installers rarely fall into these bear traps. It is mostly setups with lots of custom actions that trigger unusual problems. But there are no guarantees - I again refer to deployment's complexity and unpredictability - you never know what state the system you hit is in. To make this complexity more concrete, you can check the "The Complexity of Deployment" section here (a bit down the page): Windows Installer and the creation of WiX. Please give it a quick skim to grasp why we warn against "smart setups" - if they are not needed (sometimes there is no other option - and then QA and real-world testing are paramount issues).

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164