Wix Toolset install optional component - wix3.10

I am trying to use Wix Toolset 3.10 to install a small app. The thing I am having trouble with it getting it to launch a third-party .exe that is an optional feature.
Here is the related code in my Product.wxs file:
<Feature Id="iCalSetup" Title="Automation" Level="2">
<ComponentRef Id="icalsetup"/>
</Feature>
<Component Id="icalsetup" Guid="*" Directory="PRODUCTFOLDER">
<File Id="icalsetup" Name="foo.exe" Source="$(var.*****.TargetDir)foo.exe" KeyPath="yes"/>
</Component>
I am wrapping the ending msi in a bootstrapper application. to generate a .exe. The feature/selection tree shows the optional components correctly, but the .exe is never executed when it is selected. Please help!

I found a way to accomplish what I was looking to do. The .exe I was using was a self-extracting executable. I extracted it and created component groups for the extracted files. then I put an MsiPackage in the Bootstrapper app. if the component groups are not copied over, then the msi does not run.

Related

Hot ti Install File just in the first time with WIX

I have a component
<Component Id="ProductComponent" Guid="7935315f-4242-4c7a-a02c-6fd256805356">
<CreateFolder/>
<File
Id="propFile"
Name="aaa.properties"
DiskId="1"
Source="$(var.Project.TargetDir)"
Vital="yes"
KeyPath="yes" ></File>
<?endif?>
</Component>
I want to copy the file just on install , not upgrade.
But I can't find how to do it.
Any idea?
Have you tried using Condition element. I think you can provide a Condition inside Component element to check whether product is already installed or not. If not installed, then create file.
<Component Id="ProductComponent" Guid="7935315f-4242-4c7a-a02c-6fd256805356">
<Condition> NOT Installed </Condition>
<CreateFolder/>
<File
Id="propFile"
Name="aaa.properties"
DiskId="1"
Source="$(var.Project.TargetDir)"
Vital="yes"
KeyPath="yes" ></File>
</Component>
This is a weak spot of MSI (which WiX uses).
MSI installs a file
User modifies the file
MSI goes to install the file. Should it:
a) overwrite and lose user data
b) not overwrite and lose new applciation data
c) merge --- MSI doesn't support this.
If the user data is only one or few attributes there are tricks with custom actions to harvest the user data and reapply it but this is very tricky stuff.
IMO, the best way to approach this is never keep user data in a file installed by the installer. Take app.config appSettings element as an example. It was an atttribute that allows you to extend the file with another file that overrides the settings in the first file. Using this pattern the installer can lay down the app config and the application can create the override file and everything just works because MSI doesn't have to deal with the problem at all.

Wix Installer Is Copying a File During Build Instead of Install

I have a kind of strange issue that I've never run into before. I have a Wix installer that has the following fragment/component:
<Fragment>
<ComponentGroup Id="groupID">
<Component Id="componentID" Guid="a guid" Directory="a directory defined elsewhere">
<File Id="fileID" Source="$(var.mylibraryname.TargetPath)"/>
</Component>
</ComponentGroup >
</Fragment>
The issue is that the file defined above gets copied into the DirectoryRef when I build the Wix project, but it does not copy over when I install it. I do this type of thing pretty frequently, but have never seen this issue crop up. Why would Wix copy the file while being built? In every other instance , running the MSI does.

Creating an installer bundle using Wix Toolset

I've been asked to jump on a project and help build an installer. I'm normally a hardware guy so my coding experience is limited, especially when it comes to this particular instance.
Essentially I have a bunch of components: exe's, dll's, drivers, etc. that I would like to bundle together into one installer to deliver to the client. A coworker suggested using the Wix toolset to do this.
Most of the material I have found has only covered the very basics and it seems like I'm being asked to do something custom and a bit more nuanced. Any help in the form of some guidance on the most efficient/easiest way to do this would be a huge help. A rough outline of what I'll need to do and/or any examples would go a long way.
Thanks!
If you want to send a bundle of files, you can simply mention those specific files in Product.wxs file of wix setup project .
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="abc.exe" Guid="de34d0c6-3b9e-439c-a254-c9f695e2e389">
<File Id="abc.exe" Name="abc.exe" Source="$(var.abc_TargetDir)abc.exe" />
</Component>
<Component Id="abc.exe.config" Guid="3a38ad30-51ce-42fd-b262-1249c7087111">
<File Id="abc.exe.config" Name="abc.exe.config" Source="$(var.abc_TargetDir)abc.exe.config" />
</Component>
</Fragment>
Like the above abc.exe and the .config file, any other file can be sent using the component tag inside the ComponentGroup tag.

Installer conditionally picking up files

I'm building a Wix installer and I need two separate versions of said installer. One that picks up the latest development build of the project and one that picks up the latest release build. Currently my fragment looks like this:
<Property Id="Program.ReleaseBuild" Value="0" />
<?define ReleaseBuild = [Program.ReleaseBuild]?>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="InstallFolder">
<Component Id="TheExe" Guid="GUID_GOES_HERE">
<?if $(var.ReleaseBuild) = 1?>
<File Id="ProjectExe" Source="(Rel Project Path)/program.exe" />
<?else?>
<File Id="ProjectExe" Source="(Dev Project Path)/program.exe" />
<?endif?>
</Component>
</ComponentGroup>
</Fragment>
And I have a transform on the msi that transforms the file after build. But the problem is that the file is picked up on compile time not install time, so both version of the installer end up having the same file contained in them. Any idea how I can conditionally grab a dev file or a rel file in the same wix project?
If you want to create installation packages based on build quality (debug versus release), you can use two product configuration and select the source based on it. This way, you can run msbuild twice, one for each configuration. I don't understand the purpose of the transform you mentioned.
So here are steps you could take to accomplish this:
Create an empty solution.
Add your wixproj to it.
Add your csproj to it.
Add a reference of the csproj to the wixproj.
Modify your File[Source] to use the project reference, this way:
<File Source="$(var.MyProject.TargetPath)" Id="ProjectExe" />
The $(var.MyProject.TargetPath) will automatically get the exe from the correct path.
Create a batch file to run the msbuild twice, one for each configuration, with the following commands:
C:\> msbuild mySolution.sln /p:Configuration=Debug
C:\> msbuild mySolution.sln /p:Configuration=Release
The result will be two installation packages, one for each configuration.

WiX: keep (rename) file on uninstall

My application has a settings file which I need to keep when user uninstalls the app. Can I do this using components, or do I need to use custom actions?
This is what I have so far (not working):
<Directory Id="INSTALLLOCATION" Name="_MyApp">
<Component>
<File KeyPath="yes" Source="$(var.Source)\settings.ini" />
</Component>
<Component Id="Backup" Guid="SOME-GUID">
<Condition>REMOVE=ALL</Condition>
<CopyFile Id="settings.ini" Delete="no" SourceProperty="INSTALLLOCATION" DestinationProperty="INSTALLLOCATION" SourceName="settings.ini" DestinationName="settings.ini.bak" />
</Component>
</Directory>
If it matters, these components belong to:
<Feature Id="Default" Level="1">
<ComponentRef Id="settings.ini" />
<ComponentRef Id="Backup" />
</Feature>
I suspected this does not work because action MoveFiles runs after RemoveFiles and then there's nothing left to move, so I removed settings.ini from installer and copied it manually after installation. I was thinking this way the ini file is still there after RemoveFiles and it will be renamed. Well, the ini file is there indeed but it doesn't get renamed. Any idea why?
Windows Installer doesn't have a built-in mechanism for backing up and restoring files. Usually the solution is to use a custom action which copies the file.
I removed settings.ini from installer
and copied it manually after
installation. I was thinking this way
the ini file is still there after
RemoveFiles and it will be backed-up.
Well, the ini file is there indeed but
it doesn't get backed-up.
Try creating an uninstall log and see what happens when MoveFiles is executed. As a side note, I don't see how copying the file manually after install is better than a backup custom action.