0

I've looked around at several examples on SO but I haven't been able to figure out the solution to my problem. I'm trying to specify the source file in an MSI. Here is the code snippet I have so far.

<Directory Id="TARGETDIR" Name="SourceDir">
  <Component Id ="FileAssociation" Guid="*">
    <File Id="myapp.exe" Source="myapp.exe" />
  </Component>
</Directory>

I understand SourceDir is required but I don't know how to configure it. I'm coding this by hand and I'm still very new to WiX. The goal is to make an installer for Java code. setupBuilder allows me to build a WiX installer but I have to define the .wsx configuration for additional functionality. The end goal is for associating custom file types with my app but I can't even find the executable in my MSI.

So far, the error I get is error LGHT0103 : The system cannot find the file 'wblite_debug.exe'.

I'm guessing I need to specify SourceDir to point to the directory that has the MSI installer? Am I on the right track?

Erik
  • 503
  • 1
  • 7
  • 26
  • 1
    ["Hello WiX" sample here](https://stackoverflow.com/a/47972615/129130). Sorry, can't look more at this right now. Let me throw in [WiX quick start recommendations](https://stackoverflow.com/a/25005864/129130) as well. – Stein Åsmul Jan 15 '19 at 20:58

3 Answers3

0

In the <File> element, the Source attribute specifies where to find the file.

<File Id="wblite_debug.exe" Source="[path_to_file]\wblite_debug.exe" />

BryanJ
  • 8,485
  • 1
  • 42
  • 61
  • I keep getting an error that TARGETDIR must be SourceDir so I'm not sure what to do about that. It looks like TARGETDIR has to be the root directory too. I settled on TARGETDIR since the Component element has to refer to a Directory. I tried setting `path_to_file` to the expected target path and the path of the installer but neither seem to work. I suspect there's some fundamental concept for Windows installers I'm not getting :( – Erik Jan 15 '19 at 15:00
  • @Erik, you're right, I just looked at one of my installs and I have the same. I'll update my answer to remove that part. – BryanJ Jan 15 '19 at 18:50
0

It looks like I have to do some tricks since merging with SetupBuilder has some problems. Here's the wxs file I give to SetupBuilder to get the file association I'm looking for.

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product>
    <Component Id="FileAssociation" Directory="INSTALLDIR" Guid="*">
    <CreateFolder/>
    <ProgId Id ="file.file" Description="My File">
      <Extension Id ="file" ContentType="application/file">
        <Verb Id ="open" Command="open" TargetFile="_myapp.exe" Argument='"%1"'/>
        <MIME ContentType="application/file" Default="yes" />
      </Extension>
    </ProgId>
  </Component>
  <DirectoryRef Id="INSTALLDIR">
    <Component Guid="*" Id="_Comp">
      <CreateFolder/>
      <File Id="_myapp.exe" Name="myapp.exe" Source="loc\myapp.exe"/>
    </Component>
  </DirectoryRef>
  <Feature Id="MainApplication">
    <ComponentRef Id="FileAssociation"/>
  </Feature>      
</Product>

Erik
  • 503
  • 1
  • 7
  • 26
0

Looking at your WiX code I can see that you are getting confused between the MSI destination and the source folder paths. The Directory tag is to create a folder on the machine where you run the MSI (where you want to deploy your application) - it has nothing to do with the source folders from where you package your files.

Replace your filepath with:

<File Id="wblite_debug.exe" Source= "\TESTfolder\wblite_debug.exe" KeyPath="yes"/>

As you can see, the file -> source attribute path should be written with reference to your WXS file path.

Isaiah4110
  • 9,855
  • 1
  • 40
  • 56
  • When you say replace, do you mean 'replace those five lines with this one line'? – Erik Jan 16 '19 at 16:08
  • that above is not your full code right? I am assuming you have a file tag that is defined for the "wblite_debug.exe" file? – Isaiah4110 Jan 16 '19 at 16:10
  • Also paste all the contents of your WXS file. – Isaiah4110 Jan 16 '19 at 16:10
  • Correct for the above code. I'm using the sample I gave in the answer I provided. While that is the code I provide to SetupBuilder, it isn't actually the complete configuration since SetupBuilder does some magic I don't fully grasp. – Erik Jan 16 '19 at 16:14
  • check this answer for Keypath - basically that's how it decides whether to install a file or not. https://stackoverflow.com/a/2003366/1766402 – Isaiah4110 Jan 16 '19 at 16:20
  • I kinda missed the whole setup builder thing, why are you using setup builder? I didn't understand that part? – Isaiah4110 Jan 16 '19 at 16:22
  • That was determined by the project lead. I believe its supposed to make it easier to build an MSI? I thought the same thing could be done with Launch4j . . . – Erik Jan 16 '19 at 16:24
  • okay, FYI. Once you have the wxs file created all you need to do is run candle.exe on it which converts the wxs to wixobj and the linker (light.exe) will convert the wixobj to the MSI. http://wixtoolset.org/documentation/manual/v3/msbuild/task_reference/candle.html http://wixtoolset.org/documentation/manual/v3/overview/light.html – Isaiah4110 Jan 16 '19 at 16:28
  • so I would first run your WXS with candle/light and see if you are getting the MSI. – Isaiah4110 Jan 16 '19 at 16:28
  • that way you know whether your exs works or not, then you can take setup builder as the next step. – Isaiah4110 Jan 16 '19 at 16:29
  • so looks like the candle/light worked? Setupbuilder was the problem? – Isaiah4110 Jan 16 '19 at 18:56