I've struggled with WIX for some time now. I want my program to be installed at the location the user has defined, install a service and start a program after installation.
First my msi package doesn't ask for install path.
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Test" />
</Directory>
</Directory>
</Fragment>
May someone tell me how to prompt a screen with change install path?
Second when my service will be installed there is an error which says I miss some permissions:
<File Id="FILE_Service" Source="$(var.Service.TargetPath)" />
<ServiceInstall Id="INSTALL_Service"
Name="Servcie"
Description=""
Start="auto"
ErrorControl="normal"
Type="ownProcess"/>
<ServiceControl Id="CONTROL_Service"
Name="Servcie"
Start="install"
Stop="both"
Remove="uninstall"
Wait="yes" />
May someone tell me how to start my service with admin access?
Third the installed package contains only one EXE file, no referenced assembly. May someone tell me how to tell WIX to search for references and install them?
WiX Tutorial: Quite a bit here. You should try a WiX tutorial: https://www.firegiant.com/wix/tutorial/
Links: Here is my WiX quick start tip answer - various resources and hints to deal with WiX and deployment in general.
Please note that there are alternative deployment and package creation tools that might help you make setups quicker and more reliably if you have little experience with MSI and setups.
Learning Advanced Installer - Resources
Direct link Advanced Installer Video Tutorials
Concrete Answer: Here are some attempted answers for your concrete questions:
Configurable installation directory (a bit down the page). You essentially set the ConfigurableDirectory attribute for a feature element to allow the user to select a custom installation directory (you get to the dialog where you can change the installation path by selecting "Custom" installation):
<Feature Id="FeatureDirectory" Title="FeatureDirectory" ConfigurableDirectory="MYCUSTOMDIR">
<!-- your stuff here -->
</Feature>
Major Upgrade Installation Directory: You need to read back the custom directory for major upgrades. Here is how: The WiX toolset's "Remember Property" pattern. Or it will revert to default during the major upgrade. This is because a major upgrade is an uninstall of the old version and a (re)-install of the new version.
Files: To install all required files you need to figure out by dependency scanning what files need to be deployed for your application to work, and then add them to your packages manually (or use heat.exe to auto-generate the files list to include). See the above quick start links for help, or see this hello wix style article: https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with
Service Permissions: Services should be installed with admin rights if you install the setup after a UAC elevation prompt. Most likely it does not start because there are missing files and hence broken dependencies. What credentials does the service use to run? LocalSystem?
Mock-Up: Here is a quick mock-up of something along the lines of what you need. You need to add all files and dependencies and insert the Service constructs among other things:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="WiXSample" Language="1033" Version="1.0.0.0"
Manufacturer="Someone" UpgradeCode="cb24bedf-e361-4f25-9a06-ac84ce5d6f5c">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<!--Default GUI - add reference to WixUIExtension.dll -->
<UIRef Id="WixUI_Mondo" />
<Feature Id="Core" Title="Core" Level="1" ConfigurableDirectory="INSTALLFOLDER" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="WiXSample">
<Component Feature="Core">
<File Source="D:\MyBinary.exe" />
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
Related
I've created a very simple MSI which copies some files to the ProgramFiles directory and while installing calling to custom actions found in a binary written in C#.
While installing, I can easily call any custom action I want. For example I've created an installation step where the user should enter a license, and after confirming the license it is checked against a server using logic written inside C# custom action.
But, when uninstalling, every time I add a custom action (even if it does nothing but returning Success), I get error that the installation failed.
This is how I use the uninstalling step:
<InstallExecuteSequence>
<Custom Action='TestUninstallation' After='MsiUnpublishAssemblies'>REMOVE="ALL"</Custom>
</InstallExecuteSequence>
where TestUninstallation is defined as following:
<CustomAction Id="TestUninstallation" Return="check" Execute="deferred" Impersonate="no" BinaryKey="TestCustomAction" DllEntry="Uninstall" />
The property DllEntry equals Uninstall which is a C# method which only returns Success.
After installation is completed, I'm trying to uninstall and I'm getting the UserExit dialog defined inside the AdminUISequence with the property OnExit.
Any idea what am I missing?
Debugging: Managed code is relatively easy to debug (native code is actually even easier). Here are some pointers:
Debug C# Custom Actions (Advanced Installer)
Different debugging methods / aspects
Suggestions: I think you just have a broken reference to the dll export function - in other words an erroneous dll function name / reference:
<CustomAction Id="TestUninstallation" Return="check" Execute="deferred" Impersonate="no"
BinaryKey="CustomActions" DllEntry="__ERRONEOUS FUNCTION REFERENCE__" />
Just check what the dll actually exports and match like this:
<CustomAction Id="CustomAction1" BinaryKey="CustomActions" DllEntry="CustomAction1"/>
As always the real McCoy is the check of the dll itself to see if you have the right function name (the below screen shot from this prior answer, recommended read).
This is a native code C++ dll:
This is a DTF-packaged managed code dll:
Notice that this is a native dll with the managed code stuff embedded. It yields a very different functions list, but you still have to find the function name in there that you refer to.
This is a straight-up managed code dll (no native wrapping):
And finally: this is the straight-up managed code DLL without being wrapped in a native dll shell.
Un-Uninstallable Setup: When a custom action crashes or fails during uninstallation, you will have problems getting rid of the installation (it just rolls-back and you are stuck with it installed). There are several fixes or workarounds.
The overall fix - in my view - is to not fail custom actions on uninstall, or at least condition them so you can force an uninstall by setting a property via the command line:
Set in MSI property table: SUPPRESSERROR = 0. Then - when needed - on the command line set:
msiexec.exe /x {PRODUCT-GUID} SUPPRESSERROR="1"
Inside the MSI you condition the uninstall custom action with:
REMOVE="ALL" AND SUPPRESSERROR="0"
Now the custom action will not run if SUPPRESSERROR is anything but 0.
There is an older answer with several further options: I screwed up, how can I uninstall my program? (courtesy of Wim Coenen, with me messing up his answer with more suggestions).
Boilerplate: For quick use, let me just dump a boilerplate ad-hoc custom action test project here. This assumes a C# managed code custom action project called "CustomAction1" in the same Visual Studio solution and a reference added to it in your WiX source - like you already have obviously (this is for later when we have all forgotten what the problem was and need to test again):
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="WiXCustomActionsTesting" Language="1033" Version="1.0.0.0"
Manufacturer="test" UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<UIRef Id="WixUI_Mondo" />
<Property Id="SUPPRESSERROR" Value="0" Secure="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="WiXCustomActionsTesting" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<!--BEGIN CUSTOM ACTION SECTION-->
<Binary Id="CustomActions" SourceFile="$(var.CustomAction1.TargetDir)\$(var.CustomAction1.TargetName).CA.dll" />
<CustomAction Id="TestUninstallation" Return="check" Execute="deferred" Impersonate="no" BinaryKey="CustomActions" DllEntry="CustomAction1" />
<InstallUISequence></InstallUISequence>
<InstallExecuteSequence>
<Custom Action='TestUninstallation' After='InstallInitialize'></Custom>
</InstallExecuteSequence>
<!--END CUSTOM ACTION SECTION-->
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="WiXCustomActionsTesting" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component>
<File Source="C:\Projects\MySetup\MyApp.exe">
</File>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Create WiX project
Copy paste the code, set a new Upgrade GUID
Create CustomAction project, default name
Add reference to custom action project from wix project
Add reference to WiXUIExtension.dll
Adjust path to file in component
Compile
I'm using Wix for my application installation and I trying to add to installation the Build Number from TFS as text in on of the dialogs.
All my application dll's and the installer itself has the build number as their file version.
I was able to accomplish this only by getting a file version of an existing EXE(from this post: Getting the file version of a native exe in MSBuild) but not of the running EXE.
<?define Property_ProductVersion = "!(bind.FileVersion.UXIDTEST)" ?>
<Product Id="$(var.ProductId)" Name="$(var.ProductDisplayName)" Language="1033" Version="$(var.Property_ProductVersion)" Manufacturer="$(var.Property_Manufacturer)" UpgradeCode="$(var.ProductUpgradeCode)">
<Package InstallerVersion="300" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='xxx'>
<Component Id='ttt' Guid='{AA2A781C-2324-4F9C-B96C-DCB5BB643409}'>
<File Id="UXIDTEST" Source="OriginalDatabase" ></File>
</Component>
</Directory>
</Directory>
What can I use to get the file version of the running EXE?
Help! I need to execute a managed custom action in my Wix 3.5 setup project and no matter what I've tried I can't get it to work.
I'm using the Votive integration in Visual Studio 2010. My Wix Product.wxs file is basically unchanged from the visual studio template except a few text changes:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="666ffc07-90b2-4608-a9f0-a0cc879f2ad0" Name="Product Name" Language="1033" Version="5.5.0002" Manufacturer="TiGra Astronomy" UpgradeCode="d17a5991-b404-4095-9e93-08d2db984cfd">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="Directory Name">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent" Guid="3ea5ade7-9b7b-40da-9e83-13e066a000ef"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="ASCOM Driver" Level="1">
<!-- TODO: Remove the comments around this ComponentRef element and the Component above in order to add resources to this installer. -->
<!-- <ComponentRef Id="ProductComponent" /> -->
<!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. -->
<ComponentGroupRef Id="Product.Generated" />
</Feature>
</Product>
I have set a reference to my managed custom action project, set the HARVEST property to true. The project is called WIX.CustomActions and produces WIX.CustomActions.dll and WIX.CustomActions.CA.dll
I see that Wix is processing the reference during build and the WIX.CustomActions.dll assembly shows up in the Binary table in the final setup project, but the WIX.CustomActions.CA.dll does not.
I have a CustomActions.wxs that should package and invoke the custom action:
<?xml version="1.0" encoding="UTF-8" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Binary Id="DriverRegistrationCA" SourceFile="$(var.WIX.CustomActions.TargetDir)\$(var.WIX.CustomActions.TargetName).CA.dll" />
<CustomAction Id="RegisterDriver" BinaryKey="DriverRegistrationCA" DllEntry="RegisterAscomDriver" Execute="deferred" Return="check" />
<CustomAction Id="UnregisterDriver" BinaryKey="DriverRegistrationCA" DllEntry="UnregisterAscomDriver" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="RegisterDriver" After="InstallFinalize" />
<Custom Action="UnregisterDriver" Before="RemoveFiles" />
</InstallExecuteSequence>
</Fragment>
</Wix>
I've looked at various 'howto' sources on the interweb and they are at best confusing, with contradictory advice. As I understand it, the WIX.CustomActions.CA.dll file is an unmanaged dll that loads the .NET framework and passes control to the 'real' managed custom action. However, the WIX.CustomActions.CA.dll does not get packaged in my MSI file. I've followed examples as best I can but I can't see what's wrong.
Please, has anyone got this working in Votive? Can you give me an actual working example?
You need a reference (e.g., CustomActionRef) from your product to the fragment; otherwise, it's discarded by the smart linker.
Following on from Bob Arnson's suggestion, I added the following two lines near the top of my Product.wxs file:
<CustomActionRef Id="RegisterDriver"/>
<CustomActionRef Id="UnregisterDriver"/>
That seems to have done the trick. Orca now shows that I have a Binary table, containing my CA dll, and a CustomAction entry in InstallExecuteSequence.
None of the examples I found on the web mentioned this requirement. I guess people were just recycling received wisdom with little or no understanding. So here is the answer, thanks to Bob!
Problem: After uninstalling a replacement GINA I get logged off immediately after logging on if I use the WIX 3.0 installer.
I have a replacement login process (GINA) for windows XP.
It consists of a single file placed in the system directory
C:\windows\system32\NewGina.dll
and a registry entry
(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\GinaDLL=NewGina.dll)
and I have no trouble manually installing it, running it, manually uninstalling it and logging in normally.
I can also create an installer using the Microsoft installer package in VS2008 and install, login, uninstall, login still works properly.
The problem I have is when I use the Wix installer, and I install, login, uninstall, and login, I get logged out immediately after login. After immediate logout, I was able to connect a remote regedit and dump the registry. I tried diffing before and after registries and I tried process monitor hoping to discover what the Wix installer was doing but the actions and changes (about 35,000) were a bit extensive to analyze. The registry line (listed above) was gone and windows should revert to the original msgina.dll
Since the rest of the project uses the Wix Installer, I'm hoping to use it.
Any ideas on how to get this to work and avoid the auto logoff?
Thanks
APB
My Wix script looks like
<Package InstallerVersion="200" Compressed="yes" />
<Condition Message="This application is only supported on Windows XP">
<![CDATA[(VersionNT = 501)]]>
</Condition>
<InstallExecuteSequence>
<ScheduleReboot After="InstallFinalize"/>
</InstallExecuteSequence>
<Media Id="1" Cabinet="NewGina.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="SystemFolder">
<Component Id="NewGina" Guid="cdbdfbe9-8137-4305-98cb-a05618ea0ade" >
<File Source="..\NewGina\Release\NewGina.dll" Checksum="yes" />
</Component>
<Component Id="RegistryEntries" Guid="cdbdfbe9-8137-4305-98cb-a05618ea0adf" >
<RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="GinaDLL" Value="NewGina.dll" />
</RegistryKey>
</Component>
</Directory>
</Directory>
<Feature Id="NewGina" Title="NewGina" Level="1" >
<ComponentRef Id="NewGina" />
<ComponentRef Id="RegistryEntries" />
</Feature>
This line is a little disturbing:
<RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" Action="createAndRemoveOnUninstall">
If my memory serves correctly that says create the Winlogon key during install (probably a noop) then remove the entire Winlogon key during uninstall. In you dump can you see if that registry key exists any longer? If my memory is correct, it might be all gone.
The correct authoring in any case, would be to just remove the RegistryKey/#Action attribute. You just want the RegistryValue installed and uninstalled. No special actions necessary.
I'd ask this on the WiX mailing list, but it seems to be down.
I have an application which is both a desktop app and a web app which runs locally. I've created a couple of basic WiX installers, but haven't yet used the IIS extension to create a virtual directory under IIS. I haven't been able to find a simple example of how to do this. All I need to do is create the virtual directory, set its port, and point it at a real directory which I'm creating with the rest of the installer.
A bonus would be enabling IIS on the machine if it's not already enabled, but I'm guessing that's not possible, and isn't a dealbreaker for me anyway.
If it matters, this installer will only be run on Vista machines.
Since the article mentioned by David seems lost, here is an example. This also creates an application in the virtual directory.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<Product Id="6f2b2358-YOUR-GUID-HERE-aa394e0a73a2" Name="WixProject" Language="1033" Version="1.0.0.0" Manufacturer="WixProject" UpgradeCode="225aa7b2-YOUR-GUID-HERE-110ef084dd72">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<!-- Reference existing site at port 8080 -->
<iis:WebSite Id="My.Site" Description="My Site">
<iis:WebAddress Id="My.Web.Address" Port="8080"/>
</iis:WebSite>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="WixProject">
<Component Id="IIS.Component" Guid="{6FAD9EC7-YOUR-GUID-HERE-C8AF5F6F707F}" KeyPath="yes">
<iis:WebVirtualDir Id="My.VirtualDir" Alias="foo" Directory="INSTALLLOCATION" WebSite="My.Site">
<iis:WebApplication Id="My.Application1" Name="Web Application 1"/>
</iis:WebVirtualDir>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="WixProject" Level="1">
<ComponentRef Id="IIS.Component" />
</Feature>
</Product>
</Wix>
Use iis:WebVirtualDir and iis:WebApplication from http://schemas.microsoft.com/wix/IIsExtension namespace.
I had a similar question earlier and I found the following article quite useful: Wix 3.0 Creating IIS Virtual Directory
Digging in the Google cache (which I think is now been purged by Google) I think the following is the code to the missing blog entry David Pokluda included in his answer. I had to do some reformatting to get this into SO, sorry if it's ugly.
<?xml version="1.0" encoding="UTF-8"?>
<!--
IMPORTANT
1. need to add the schema iis.xsd to the property window
2. add the following iis namespace
3. add the Visual Studio reference WixIIsExtenion
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<Product Id="7b523f47-YOUR-GUID-HERE-fea6be516471"
Name="Vince Wix 3 Web Service"
Language="1033"
Version="1.0.0.0"
Manufacturer="Vince LLC"
UpgradeCode="0a8c10df-YOUR-GUID-HERE-50b9ecdb0a41">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="WebAppWixProject.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="WebApplicationFolder" Name="MyWebApp">
<Component Id="ProductComponent" Guid="80b0ee2a-YOUR-GUID-HERE-33a23eb0588e">
<File Id="Default.aspx" Name="Default.aspx" Source="..\MyWebApp\Default.aspx" DiskId="1" />
<File Id="Default.aspx.cs" Name="Default.aspx.cs" Source="..\MyWebApp\Default.aspx.cs" DiskId="1"/>
<iis:WebVirtualDir Id="MyWebApp" Alias="MyWebApp" Directory="WebApplicationFolder" WebSite="DefaultWebSite">
<iis:WebApplication Id="TestWebApplication" Name="Test" />
</iis:WebVirtualDir>
</Component>
</Directory>
</Directory>
</Directory>
<!--
IMPORTANT
Add a virtual directory to an existing web site
If put it inside the Component, a new Web Site will be created and uninstall will remove it
-->
<iis:WebSite Id='DefaultWebSite' Description='Default Web Site' Directory='WebApplicationFolder'>
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
<Feature Id="ProductFeature" Title="Vince Wix 3 Web Service" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>
<!--
IMPORTANT
To get rid of light.exe location error, do the following on the Linker Tab:
Set culture to: en-US
Supress Schema Validation in the Advanced Button
-->
I'm not familiar with WiX, but both IIS 6 and 7 can be managed using WMI (Windows Management Instrumentation) objects. I've used both PowerShell and C# to create websites, virtual directories, permissions etc on IIS. You should be able to get your hands on these objects from most scripting environments.
The above snippets use the iis:WebAddress in an improper way. You need to add IP="*" if you want this to work with all websites that match the name and the port. The above example fails during the install if there is an ip address assigned to the website in IIS (wix CA will not find it in general)
Rant: wix is terrible for many reasons, in my opinion and this is a good example. If the attribute is missing it will only work for websites with the default IP - how unintuitive is this. Wix should at least emit a waring for a missing IP element. Furthermore the default IP (localhost) is represented as * in IIS metabase, at the same time in the wix file * means all websites (not only *). So it is really confusing and not intuitive at all.