Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExePackage elements need DetectCondition attribute #3

Open
robmen opened this issue Feb 13, 2017 · 8 comments
Open

ExePackage elements need DetectCondition attribute #3

robmen opened this issue Feb 13, 2017 · 8 comments

Comments

@robmen
Copy link

robmen commented Feb 13, 2017

In the example in the Samples wiki, the ExePackage element does not have a DetectCondition attribute. You need a DetectCondition for UninstallCommand to be called. Honestly it is a long standing mistake in the WiX Toolset that the DetectCondition was not required that is planned to be fixed in WiX Toolset v4.

Would be good to add the DetectCondition attribute to the example.

@heaths
Copy link
Member

heaths commented Feb 13, 2017

Will do. With previous releases there was no cheap way to detect extensions' presence but the new query API could make that possible now for v3s (doesn't have to load the entire Extension Manager API). Is that something BA functions could enable?

@heaths
Copy link
Member

heaths commented Feb 13, 2017

Actually, that still wouldn't work for previous extension versions or on previous releases. If the DetectCondition were always false, it would at least attempt to install the extension each time which is almost a no-op (incurs detection time across all installed versions) to VSIXInstaller of the extension is installed.

@heaths
Copy link
Member

heaths commented Mar 13, 2018

This came up today in a discussion. Basically, there's no conceivable way to author a DetectCondition that works for multiple instances. This is why in the WIP I recommend generating install commands at runtime, which currently to my knowledge is not supported by Burn nor am I advocating that it should be.

However, to support uninstall, would it be possible to rely on a BA function? It seems, however, only a single BA function is supported and not something that can be provided by an extension.

@oold
Copy link

oold commented Oct 4, 2022

I have been trying to incorporate the bootstrapper into a WiX bundle for our internal extensions. It has been rather troublesome so far. We've had issues with the installer failing if we're just doing something like:

<ExePackage DisplayName="VS Ext 1" Id="Vsix1" SourceFile="VSIXBootstrapper.exe" InstallCommand="/q ext1.vsix" Permanent="yes" DetectCondition="WixBundleInstalled">
	<PayloadGroupRef Id="Vsix1" />
	<ExitCode Behavior="success" Value="0" />
	<ExitCode Behavior="success" Value="2" />
	<ExitCode Behavior="success" Value="2003" />
</ExePackage>

I don't exactly know why, but it sometimes this fails if the extension is already installed, so I proceeded to add this:

<ExePackage DisplayName="Remove VS Ext 1" Id="RemoveVsix1" SourceFile="VSIXBootstrapper.exe" InstallCommand="/q /u:MY-GUID" UninstallCommand="/q /u:MY-GUID" DetectCondition="WixBundleInstalled">
	<PayloadGroupRef Id="VSIXBootstrapper" />
	<ExitCode Behavior="success" Value="0" />
	<ExitCode Behavior="success" Value="2" />
	<ExitCode Behavior="success" Value="1002" />
</ExePackage>

That has worked, except that an upgrade now uninstalls the extension, installs the extension, and then runs the uninstaller of the previous version, which uninstalls the extension again.
So I copied the entire standard bootstrapper code and modified it to set a variable if the installer is called as part of an upgrade. I'm using that variable in the detect condition which now looks like this: WixBundleInstalled AND NOT IsRunAsPartOfUpgrade.
Everything seemed to work now, but upgrading the installation takes ages thanks to all the stuff the VSIX installer is doing during every action.

Got another bug report today. The uninstaller failed:

[5318:9FA4][2022-10-04T16:36:01]i301: Applying execute package: RemoveVsix1, action: Uninstall, path: C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\VSIXBootstrapper.exe, arguments: '"C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\VSIXBootstrapper.exe" /q /u:RemoveVsix1-GUID'
[5318:9FA4][2022-10-04T16:36:42]i319: Applied execute package: RemoveVsix1, result: 0x0, restart: None
[5318:9FA4][2022-10-04T16:36:42]i301: Applying execute package: RemoveVsix2, action: Uninstall, path: C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\VSIXBootstrapper.exe, arguments: '"C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\VSIXBootstrapper.exe" /q /u:RemoveVsix2-GUID'
[5318:9FA4][2022-10-04T16:37:25]e000: Error 0xe0434352: Process returned error: 0xe0434352
[5318:9FA4][2022-10-04T16:37:25]e000: Error 0xe0434352: Failed to configure per-user EXE package.
[5318:9FA4][2022-10-04T16:37:25]i319: Applied execute package: RemoveVsix2, result: 0xe0434352, restart: None
[5318:9FA4][2022-10-04T16:37:25]e000: Error 0xe0434352: Failed to execute EXE package.
[5318:9FA4][2022-10-04T16:37:25]i351: Removing cached package: RemoveVsix2, from path: C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\
[5318:9FA4][2022-10-04T16:37:25]i301: Applying rollback package: RemoveVsix1, action: Install, path: C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\VSIXBootstrapper.exe, arguments: '"C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\VSIXBootstrapper.exe" /q /u:RemoveVsix1-GUID'
[5318:9FA4][2022-10-04T16:37:25]e000: Error 0x80070003: Failed to CreateProcess on path: C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\VSIXBootstrapper.exe
[5318:9FA4][2022-10-04T16:37:25]e000: Error 0x80070003: Failed to configure per-user EXE package.
[5318:9FA4][2022-10-04T16:37:25]i319: Applied rollback package: RemoveVsix1, result: 0x80070003, restart: None
[5318:9FA4][2022-10-04T16:37:25]i351: Removing cached package: RemoveVsix1, from path: C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\
[5318:9FA4][2022-10-04T16:37:25]w353: Unable to remove cached package: RemoveVsix1, from path: C:\Users\user\AppData\Local\Package Cache\PACKAGE-CACHE-GUID\, reason: 0x80070003. Continuing...
[5318:9FA4][2022-10-04T16:37:25]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BUNDLE-GUID}, resume: ARP, restart: None, disable resume: No
[5318:9FA4][2022-10-04T16:37:25]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BUNDLE-GUID}, resume: ARP, restart initiated: No, disable resume: No
[5318:9FA4][2022-10-04T16:37:25]i399: Apply complete, result: 0xe0434352, restart: None, ba requested restart:  No

Some kind of .NET exception happened in the VSIX Installer, then the cache directory... got cleared? No real idea what's happening there, but we can't uninstall.

Actual guidance on how to use the VSIX Bootstrapper in a WiX bundle would be nice because that wiki page is just wrong and leaves everyone trying to implement such an installer to a lot of guesswork. I'm almost tempted to just write my own VSIX bootstrapper that does all this stuff internally because trying to wrap WiX around this utility is painful to say the least.

@heaths
Copy link
Member

heaths commented Oct 4, 2022

The VSIXBootstrapper is just a thin wrapper around VSIXInstaller. If VSIXInstaller failed, as you noted above, please file a bug report at https://developercommunity.visualstudio.com.

@oold
Copy link

oold commented Oct 4, 2022

I'm aware that I should file a bug report there for that specific issue, but thanks for mentioning it. I'll try to gather more data about that issue and might post the bug report then.

@yang-shuaijun
Copy link

How to write the DetectCondition expression? Colud you provide the example? I'm confused with this attribute.

@heaths
Copy link
Member

heaths commented Nov 27, 2023

How to write the DetectCondition expression? Colud you provide the example? I'm confused with this attribute.

@yang-shuaijun please see https://wixtoolset.org for docs and support of WiX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants