dan radu
dan radu

Reputation: 2782

How do I detect an application was installed via ClickOnce, using WiX?

I'm writing a WiX installer for an application which was deployed previously using ClickOnce.

I would like to detect if the application was installed on the client computer and abort the MSI installation. I searched similar questions on Stack Overflow, but I couldn't find a way to do that.

If I can find a path or some registry key that tells me where the application was installed, I can abort the MSI installation via a Condition.

Using the answer for this question, I was able to get somewhere. The ClickOnce shortcuts are files with the .appref-ms extension. This is the code I use:

<Property Id="APP_CLICKONCE_INSTALLED">
    <DirectorySearch Id="dirSearch.APP.CLICKONCE" AssignToProperty="yes" Path="[StartMenuFolder]" Depth="2">
    <FileSearch Id="fileSearch.APP.CLICKONCE" Name="APP.appref-ms" />
    </DirectorySearch>
</Property>

<Condition Message="App is already installed. Please uninstall it then re-run this setup.">
    <![CDATA[APP_CLICKONCE_INSTALLED = "" OR INSTALLED]]>
</Condition>

However, StartMenuFolder gives the location for AllUsers profile, whereas the click once application is installed for the current user. I am still digging.

Using perUser installation the StartMenuFolder gives the current user location (I was using perMachine):

<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" />

All is good now.

Upvotes: 3

Views: 1886

Answers (1)

RobinDotNet
RobinDotNet

Reputation: 11877

I don't know anything about WiX, but another way to tell if a ClickOnce application is installed is to iterate through the uninstall strings in the registry, which are here:

HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall

You'll want to search for one where the product name of your application matches the Display Name for that set of keys.

Upvotes: 5

Related Questions