-1

I had a perfectly good wix installer when it came to moving files from the cab file to the hard drive. The problems are all being caused by the way I am writing my custom action. First, I will show the culprit, then explain the symptoms.

<CustomAction Id="InstallElasticWithProvidedBatch" FileKey="fil85D231A31B2F8EB99C6B9EA4B95A354C" Impersonate="no" ExeCommand="install" Execute="deferred"/>
<CustomAction Id="RemoveElasticWithProvidedBatch" FileKey="fil85D231A31B2F8EB99C6B9EA4B95A354C" Impersonate="no"    ExeCommand="remove" Execute="deferred"/>

<InstallExecuteSequence>
  <Custom Action='InstallElasticWithProvidedBatch' Before='InstallFinalize'>NOT Installed</Custom>

  <Custom Action='RemoveElasticWithProvidedBatch' Before='InstallFinalize'>REMOVE ~= "ALL"</Custom>

</InstallExecuteSequence>

What this code is supposed to be doing:

Run the service.bat script to install and uninstall elastic search as a service. When the application is first installed, it should run the bat with the parameter "install." When the application is uninstalled, it should run the bat with the perameter "remove."

What is happening (read a few times. It is pretty interesting):

Install goes perfectly fine! The files get put on disk and the service is installed properly. When I uninstall it, I get this message:

enter image description here

The application is then stuck in my Add/Remove programs menu and I have to manually delete the installed files and then sift through the registry to clear out the elastic search entry.

on SUBSEQUENT installs. The error message I linked you moments ago does not come back! AND the service is correctly removed. BUT the files that were installed now don't get touched anymore.

To reset the situation, I have to change the GUID on every single file referenced in the xml document, but that just gets me back to where the install says it doesn't have the program it needs to uninstall the application properly.

If I remove the custom actions, the installer works as intended (assuming I have changed all 50 guids since the last time the installer broke). Does anyone have any hints as to what to try next? I have burnt 5 hours on this issue.

Side note: A common thing for the WIX veterans to say is to not use a batch file at all and just convert the files functionality into native Wix, but that is not a very valuable process in this case. The .bat file is provided by elasticsearch and is incredibly cryptic.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Shadoninja
  • 1,276
  • 1
  • 12
  • 22
  • If this is a third party component you should chase the vendor and ask them to deliver a better runtime version of their component. For example an MSI, an EXE, an ActiveX inf installer or a merge module, or all of the options. – Stein Åsmul May 05 '15 at 09:22
  • I replied to my problem with the solution. My second custom action wasn't executing until after the uninstall deleted the batch file it was trying to use. It makes sense now, but the behavior that was caused by it had me running miles in the wrong direction. – Shadoninja May 05 '15 at 16:53

3 Answers3

1

I figured out my problem! It was one of the attributes on this line

<Custom Action='RemoveElasticWithProvidedBatch' Before='InstallFinalize'>REMOVE ~= "ALL"</Custom>

The correct way to write this line in my case was

<Custom Action='RemoveElasticWithProvidedBatch' After='InstallInitialize'>REMOVE ~= "ALL"</Custom>

The attribute Before='InstallFinalize' caused the batch file to be killed before the installer got a chance to run it. This lead to the installer being unable to remove the installed files. To work around this, I would manually remove the installed program from my Add/Remove Programs directory by deleting the registry entry. Manually removing them caused the MSI to completely ignore the GUID's on future uninstalls. Because of that, the SECOND time I would run the life cycle of the msi, the bat file would properly run since all installed files are left alone this time (when they should be deleted). An incredibly hard-to-see problem cause by a single misplaced attribute....

Shadoninja
  • 1,276
  • 1
  • 12
  • 22
  • I don't really understand stackoverflow for people that are new to programming. I don't have control over whether or not I am using the bat files in the install. I wish I did, but I don't. I know it is bad practice to use them and stated that upfront with the initial posting of my question. I had a real problem and spent hours trying to figure it out before considering a post. I post the problem here finally, then figure out a solution later and post it to try to help others. Now I get downvoted and continue to be throttled from posting new questions due to my low reputation. Very frustrating. – Shadoninja May 06 '15 at 18:00
  • The bat file is over 200 lines long with nothing but convoluted variable uses and goto statements. It installs registry keys in various places and touches a lot of places on the system. Two senior people here directly told me to not spend the time to decipher that since it was the first install like that. I get one stack overflow question every 7 days, currently. I was descriptive with my problem, posted code, took screen shots of errors, and gave a detailed answer when I figured out what is wrong and now I am -1 for this whole thread. I honestly don't think you feel me right now. – Shadoninja May 06 '15 at 20:49
  • I am in no way questioning your authority on the topic. You are arguing for a point that I never challenged in the first place. I wrote a thorough post summarizing the problem (while at the same time expressing awareness of its less-than-desirable nature). I wrote a complete answer as to how I fixed it and why it was behaving the way it was and then lost reputation in the end. – Shadoninja May 06 '15 at 21:49
  • Don't throw your salary at me. I openly recognized it wasn't best-practice in my original post. Yet you "donated" (but really wasted) hundreds of dollars of your time to ignore that and bullheadedly "teach" me about WIX. – Shadoninja May 07 '15 at 05:02
  • 2
    You condescendingly argue with me for an entire day, then erase all the evidence. You are a true leader of the stackoverflow community. – Shadoninja May 07 '15 at 16:05
1

The .bat file is provided by elasticsearch and is incredibly cryptic.

Please add the batch file so we can take a look. Installing with batch files is not good practice at all. It is error prone and vulnerable.


The following was written before your final comment above:

Run the service.bat script to install and uninstall elastic search as a service.

You should not install a service with a batch file. You should use the built in ServiceInstall and ServiceControl tables. These tables feature a nice degree of "auto-magic" when configured correctly, and will prevent side effects from your own scripted or batched solutions.

The application is then stuck in my Add/Remove programs menu and I have to manually delete the installed files and then sift through the registry to clear out the elastic search entry.

This is dangerous. Manually sifting through the registry to delete Windows Installer residue is a common way to destroy your whole computer installation since Windows Installer can get into a locked state not allowing you to install or uninstall at all.

on SUBSEQUENT installs. The error message I linked you moments ago does not come back! AND the service is correctly removed. BUT the files that were installed now don't get touched anymore.

The previously installed version is likely still registered in the Windows Installer database in the registry. Changing the component guids will work around this, but there is still unregistered items in the registry.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • I figured out the problem. I posted the answer to it as my reply. It makes sense now, but it was quite a tricky thing to figure out at the time. I would love to cut out the bat file, but I just can't even begin to understand what it is doing. Here is the pastebin link: http://pastebin.com/Y0XABSm2 – Shadoninja May 05 '15 at 16:50
0

The question was: "Why is my Wix Custom Action is breaking my installer"

The looking at the forest instead of the trees answer is that it's breaking your installer because it's a 300 line .BAT file. Simply put it's an out of process, reinventing the wheel with an inferior solution anti-pattern.

You can fix it here and there to get it to work now and then but it really needs to go. You have every excuse on why it can't go so this answer is for the next person with a similar problem who is more interested in being a software professional.

In cases like this I find it's not important to understand every little line of the .BAT file. It's crap, you can assume 90% of it is stupid.

What I do see is things like 32bit vs 64bit, java detection and so on. This gets translated into mutually exclusive components and app search / launch conditions and so on.

What's really important is to observe the possible final installed states of the application and work with that as your requirements. It doesn't really mater exactly why the custom action is failing your install (this time) the important point is it's fragile crazy stupid coding and it is likely to fail you a dozen different ways.

See my answer here: Wix installer to replace INSTSRV and SRVANY for user defined service installation I like to say that a service is a service is a service. I have yet to come across a service that MSI couldn't handle given the right details.

Community
  • 1
  • 1
Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • More passive aggressive comments! Excellent use of your seniority. Hopefully you don't change this response later like you did with the rest of your digs at me. I am certain this approach will be useful to someone down the road. Thanks. – Shadoninja May 07 '15 at 20:47