VSIX package gets installed by Wix but not uninstalled - wix

I created a Wix installer that installs a VSIX using the VsixPackage extension. The VSIX gets installed properly however two things are bugging me:
The user has the possibility to uninstall the VSIX through the tools / Extensions menu in VS.
When I uninstall the MSI, the VSIX doesn't get uninstalled.
I did set the Permanent attribute of the VsixPackage to no. Here is the markup:
<Component Id="VSIXVS11"
Guid="2C85F474-3E44-4A38-AC2D-0A6F6B1049DA">
<VSExtension:VsixPackage File="MvvmLight.VS2012.vsix"
PackageId="MVVM Light..e8b05c55-a169-42aa-a116-064ef2205f80"
Target="professional"
TargetVersion="11.0"
Vital="yes"
Permanent="no"/>
<File Id="MvvmLight.VS2012.vsix"
Name="MvvmLight.VS2012.vsix"
DiskId="1"
Source="..\..\InstallItems\VSIX\Release\MvvmLight.VS2012.vsix" />
</Component>
Any idea what causes the VSIX to not get uninstalled?
Note: The VSIX's "This VSIX is installed by Windows Installer" flag is not set. If I try to set it, I get an error when running the MSI.

You have a space in the package ID.
Escape the package ID like so:
<VSExtension:VsixPackage File="MvvmLight.VS2012.vsix"
PackageId=""MVVM Light..e8b05c55-a169-42aa-a116-064ef2205f80""
Target="professional"
TargetVersion="11.0"
Vital="yes"
Permanent="no"/>

Related

Make Wix to not uninstall common dll

I have Wix project in which I need a common used dll library to be installed if it's absent.
If this dll exists I should not overwrite it.
So, when I set DefaultVersion="0.0.0.0" this dll is not overwritten if it exists, its ok. But when I delete app, the dll is beeing removed. How do I prevent removing dll in the case when it existed before installation?
I don't want to make it permanent because it should be removed if it didn't exist before installation.
<Component Id="myLib.dll" Permanent="no" Directory="Shared_Dir">
<File Name="myLib.dll" KeyPath="yes"
Source="mySource\myLib.dll"
DefaultVersion="0.0.0.0"
/>
Add reference to WixUtilExtension and xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" attribute to Wix element in your code.
Define <Property Id="Dll_Installed" Value="false"/> in Product element.
Add child <Condition>NOT Dll_Installed</Condition> to component myLib.dll.
Add that somewhere in your code:
<Fragment>
<util:FileSearch
Id="Dll_Installed"
Variable="Dll_Installed"
Path="[Shared_Dir]myLib.dll"
Result="exists"/>
</Fragment>
DefaultVersion attribute is not necessary.
The feature you are describing is reference counting. The Windows Installer reference counts with Components. Components are identified by their GUID.
So the normal way to address this requirement is to put the File in a Component and make sure the GUID of the Component is stable. The WiX Toolset should do exactly that automatically if if you do not specify the Component/#Guid attribute.
So the default behavior should just work for you.
The only other piece of the puzzle is the Windows Installer will install the latest version of a file. If the file version is the same or less the file will not be installed but will be reference counted.
Based on the details in the question it seems like you should be just fine with:
<Component Directory="Shared_Dir">
<File Source="mySource\myLib.dll" />
</Component>
One might ask why the Windows Installer use Components to reference count files. We'll, it allows you to group other resources, like registry keys, together and control their install as a unit. Much more important if you are installing COM servers than plain old files.

In a WiX Bundle, how can I supply a settings file for an ExePackage?

I am authoring a WiX bundle that installs several other pre-build packages, some are MSIs and some are EXEs.
One of the EXE packages requires a settings file to be supplied which I have to give the path to on the command line.
<ExePackage Id="exePackage"
Description="Executable Installer"
PerMachine="yes"
InstallCommand="-settings=TheConfigurationFile.txt"
SourceFile="RedistributablePackages\TheInstaller.exe" >
How should I package TheConfigurationFile.txt so that the EXE installer can find it? It isn't clear to me how to do that as I can't seem to find any way to specify a file in connection with the ExePackage...?
Check out the Payload element.
<Payload SourceFile="TheConfigurationFile.txt"/>

How to uninstall with msiexec using product id guid without .msi file present

I'm trying to automate the uninstallation of packages created using WiX for the purposes of changing the installed software stack & configuration without reprovisioning a whole OS. Eventually I'll use powershell scripting to do this but at the moment I can't seem to get my test package to uninstall interactively with cmd.
If I run:
msiexec /x '{A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8}'
msiexec /x A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8
I get:
"The installation package could not be opened. Verify that the package
exists and that you can access it, or contact the application vendor
to verify that this is a valid Windows Installer Package."
If I run:
msiexec /x {A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8}
I get:
"This action is only valid for products that are currently installed"
I've looked at the windows installer guide, the WiX documentation, msiexec documentation and used orca to go over the .msi myself but I've not really found anything that gives a clear picture of how an uninstall is processed. Is the .msi file required and if not then why does windows installer seem to think it is when given a GUID?
The WiX code for the .msi installer is:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='htp://schemas.microsoft.com/wix/2006/wi' >
<!--DO NOT COPY / PASTE THE PRODUCT ID GUID BELOW TO YOUR OWN WIX SOURCE -->
<Product Id='A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8' Language='2057'
Manufacturer='COMPANYNAME IT-Operations'
Name='COMPANYNAMEServerListener' Version='1.0.0'
UpgradeCode='PUT-GUID-HERE'>
<Package Id='*' Manufacturer='COMPANYNAME IT-Operations' Compressed='yes' />
<Media Id='1' Cabinet='COMPANYNAMEServerListener.cab' EmbedCab='yes' />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='COMPANYNAME' Name='COMPANYNAME'>
<Directory Id='INSTALLDIR' Name='COMPANYNAMEServerListener'>
<Component Id='MainExecutable' Guid='*' >
<File Id='COMPANYNAMEServerListener.exe'
Source='COMPANYNAMEServerListener.exe' Vital='yes'
KeyPath='yes' />
<ServiceInstall
Id='COMPANYNAMEServerListenerInstall'
DisplayName='COMPANYNAMEServerListener'
Description='Accepts and discards TCP connections on port 28028 to indicate that this server is alive and ready to be controlled'
Name='COMPANYNAMEServerListener'
Account='NT AUTHORITY\LocalService'
ErrorControl='normal'
Start='auto'
Type='ownProcess'
Vital='yes'
>
<ServiceDependency Id='tcpip'/>
</ServiceInstall>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="COMPANYNAMEServerListener" Wait="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id='Complete' Level='1' >
<ComponentRef Id='MainExecutable' />
</Feature>
<CustomTable Id ="COMPANYNAMEMetadata">
<Column Id="Property" Type="string" Category="Identifier" PrimaryKey="yes"/>
<Column Id="Value" Type="string"/>
<Row>
<Data Column="Property">InstallString</Data>
<Data Column="Value">/qn</Data>
</Row>
</CustomTable>
</Product>
</Wix>
"Reference-Style" Answer: This is an alternative answer to the one below with several different options shown. Uninstalling an MSI file from the command line without using msiexec.
The command you specify is correct: msiexec /x {A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8}
If you get "This action is only valid for products that are currently installed" you have used an unrecognized product or package code, and you must find the right one. Often this can be caused by using an erroneous package code instead of a product code to uninstall - a package code changes with every rebuild of an MSI file, and is the only guid you see when you view an msi file's property page. It should work for uninstall, provided you use the right one. No room for error. If you want to find the product code instead, you need to open the MSI. The product code is found in the Property table.
UPDATE, Jan 2018:
With all the registry redirects going on, I am not sure the below registry-based approach is a viable option anymore. I haven't checked properly because I now rely on the following approach using PowerShell: How can I find the product GUID of an installed MSI setup?
Also check this reference-style answer describing different ways to uninstall an MSI package and ways to determine what product version you have installed:
Uninstalling an MSI file from the command line without using msiexec
Legacy, registry option:
You can also find the product code by perusing the registry from this base key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall . Press F3 and search for your product name. (If it's a 32-bit installer on a 64-bit machine, it might be under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall instead).
Legacy, PowerShell option: (largely similar to the new, linked answer above)
Finally, you can find the product code by using PowerShell:
get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name
Similar post: WiX - Doing a major upgrade on a multi instance install (screenshot of how to find the product code in the MSI).
msiexec.exe /x "{588A9A11-1E20-4B91-8817-2D36ACBBBF9F}" /q
The good thing is, this one is really easily and deterministically to analyze:
Either, the msi package is really not installed on the system or you're doing something wrong.
Of course the correct call is:
msiexec /x {A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8}
(Admin rights needed of course- With curly braces without any quotes here- quotes are only needed, if paths or values with blank are specified in the commandline.)
If the message is: "This action is only valid for products that are currently installed", then this is true. Either the package with this ProductCode is not installed or there is a typo.
To verify where the fault is:
First try to right click on the (probably) installed .msi file itself. You will see (besides "Install" and "Repair") an Uninstall entry. Click on that.
a) If that uninstall works, your msi has another ProductCode than you expect (maybe you have the wrong WiX source or your build has dynamic logging where the ProductCode changes).
b) If that uninstall gives the same "...only valid for products already installed" the package is not installed (which is obviously a precondition to be able to uninstall it).
If 1.a) was the case, you can look for the correct ProductCode of your package, if you open your msi file with Orca, Insted or another editor/tool. Just google for them. Look there in the table with the name "Property" and search for the string "ProductCode" in the first column. In the second column there is the correct value.
There are no other possibilities.
Just a suggestion for the used commandline: I would add at least the "/qb" for a simple progress bar or "/qn" parameter (the latter for complete silent uninstall, but makes only sense if you are sure it works).
There's no reason for the {} command not to work. The semi-obvious questions are:
You are sure that the product is actually installed! There's something in ARP/Programs&Features.
The original install is in fact visible in the current context. It looks as if it might have been a per-user install, and if you are logged in as somebody else now then it won't know about it - you'd need to log in under the same account as the original install.
If the \windows\installer directory was damaged the cached file would be missing, and that's used to do the uninstall.
Thanks all for the help - turns out it was a WiX issue.
When the Product ID GUID was left explicit & hardcoded as in the question, the resulting .msi had no ProductCode property but a Product ID property instead when inspected with orca.
Once I changed the GUID to '*' to auto-generate, the ProductCode showed up and all works fine with syntax confirmed by the other answers.
Try this command
msiexec /x {product-id} /qr
you need /q at the end
MsiExec.exe /x {2F808931-D235-4FC7-90CD-F8A890C97B2F} /q

WiX bootstrapper: Uninstall packages in a chain

<ExePackage Id="PackageID1" DisplayName="xxx" Compressed="yes"
SourceFile="..\xxx\MyExe.exe" Vital="yes"
InstallCommand="parameters to the exe"
UninstallCommand="parameters to the exe"/>
When I trigger the Uninstall action:
this.Engine.Detect();
this.Engine.Plan(LaunchAction.Uninstall);
this.Engine.Apply(System.IntPtr.Zero);
The exePackage does not get invoked. However, during Install, it enters the exe package with the right parameters.
Am I missing something here?
You need a DetectCondition attribute on your ExePackage element. The DetectCondition is how the Burn engine determines if the package is installed on the machine or not. Without a DetectCondition the engine will think the package is never installed so it will never need to be uninstalled. Since all executables are different you have to provide your own DetectCondition. Usually the XxxSearch elements in the util namespace are helpful to detect if your executable is installed.
Note: you can see the 'plan' in the log file and it should show the PackageID1 package being detected as 'Absent' even though it is installed.

How to fix ICE57.Per-User installation

Our application writes some settings to the registry into the HKCU hive during runtime. I want to delete this settings during uninstall. Here is code:
<Fragment>
<DirectoryRef Id="INSTALLLOCATION" DiskId="1" FileSource="$(var.SourceDirProject)\">
<Component Id="DeleteHkcuManufacturerHive" Guid="GUID">
<Condition>REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE</Condition>
<CreateFolder/>
<RemoveRegistryKey Action="removeOnUninstall"
Id="HKCUkey" Root="HKCU" Key="Software\$(var.Manufacturer)"/>
</Component>
</DirectoryRef>
</Fragment>
ICE57: Component 'DeleteHkcuManufacturerHive' has both per-user and per-machine data with a per-machine KeyPath.
Why I'm getting ICE57? Installation is per-User. Thank's in advance.
UPD: Where is here the per-machine element? May be it is an INSTALLLOCATION=Program Files\ManufacturerDirectory?
You are operating on the HKCU hive which is only available to the current user.
MSDN states:
ICE57 validates that individual components do not mix per-machine and
per-user data. This ICE custom action checks registry entries, files,
directory key paths, and non-advertised shortcuts. Mixing per-user and
per-machine data in the same component could result in only partial
installation of the component for some users in a multi-user
environment.
The ICEs are validations on your installation package. As stated above, ICE57 is to make sure you don't mix up per-machine and per-user constructs. If you must remove entries to HKCU during uninstall (and the software is installed per-machine) then you can turn off that specific validation in Visual Studio in Properties > Tool Settings as shown in the screenshot below:
However, you may want to think about the root cause of your issue. If you are doing a per-machine install, your installer or application should probably not be writing to HKCU as it is only available to the current user, whereas your app is installed for all users.
I've got an answer on wix-users mailing list. Here is Peter Shirtcliffe's answer:
ProgramFiles is a per-machine location. You can only access it when elevated. If you want to install program code in a per-user installation, you should install to %LocalAppData%\Programs.
Remove the condition entirely. The component will be installed but will have no effect until you uninstall the application. At that point, when the component is removed, the registrykey will be removed also.