Add Zip Files to TARGETDIR in WiX

1

In my Visual Studio 2017 solution, I have a WiX 3 setup project that pulls in the output several other projects (libraries, executables, assets, content). Under the directory structure for the solution but not added to the solution as a project, I have a project that compiles some browser extensions using webpack. This webpack project outputs to an artifacts folder with subdirectories for each browser. Inside each subdirectory is the compiled extension with the version number included in the file name like:

  • artifacts
    • Chrome
      • myextension-0.1.0.0.zip
      • myextension-0.1.0.1.zip
      • myextension-0.1.0.2.zip

At compile time, ultimately I want to include the files matching the version number i.e. myextension-\$(var.VERSION).zip into the MSI package so it can then be placed into the application folder during installation. Even when I hard-code the version number i.e. myextension-0.1.0.2.zip into the component, I get an error from light:

LGHT0001: The system cannot find the path specified. (Exception from HRESULT: 0x80070003)

I'm getting the directory with a define like this:

<?define ChromeTargetDir=$(var.SolutionDir)Extensions\artifacts\chrome\?>

And then my component looks like this:

<Component Id="ChromeExt"
             Location="local"
             Guid="GUID_HERE">
    <CreateFolder/>
    <File Id="ChromeExtension"
          Name="myextension-0.1.0.2.zip"
          Source="$(var.ChromeTargetDir)myextension-0.1.0.2.zip"
          KeyPath="yes"/>
</Component>

When I look in the wixobj created by candle, I see the full correct path replaced for the file where it resides on my system:

<field>C:\Users\me\source\repos\mysolution\Extensions\artifacts\chrome\myextension-0.1.0.2.zip</field>

So my question is, what is the correct way to include "arbitrary" files in my WiX project?

wix
wix3
wix3.11
asked on Stack Overflow Sep 19, 2018 by Dewey Vozel

1 Answer

0

1) Solution vs Project Dir: The first thing I would try would be to replace $(var.SolutionDir) with $(var.ProjectDir) and try a recompile. I'll follow up if the problem is something else. Let's just rule that out first.

2) Quotes: I also use quotes around my paths:

<?define ChromeTargetDir="C:\Sources\Packages\MyChromeExtension\Files\" ?> 

3) Project Variables: And finally you need a reference added to your project for project references and variables to work: WiX: How to use relative path to SolutionDir.


Obscure: More obscure causes could be lacking access rights (file not seen by the build process and light.exe - running impersonated?). Corrupted file or folder? (try to replace). And whatever else might conspire against you. Locked files?

answered on Stack Overflow Sep 19, 2018 by Stein ├ůsmul • edited Sep 19, 2018 by Stein ├ůsmul

User contributions licensed under CC BY-SA 3.0