Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WIX - Getting source files from an environment variable path

Tags:

wix

I'am new to WIX, trying to create an msi with feature tree.

  1. The installer should install all the assemblies in folder C:\ProgramFile\MyDir\MyApp.
  2. Reading path from an environment variable called MyFolder.

    <WixVariable Id ="MyFolder" Value="[%MyFolder]"/>
    
  3. Below is the code from where the assemblies are read.

    <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
    <Directory Id="ProgramFilesFolder.MyDIR" Name="MyDIR">
    <Directory Id="PROGRAMFILESFOLDER.MyDIR.MyApp" Name="MyApp">
    
    <Component Id="Component.aaa.dll" Guid="guid1">
      <File Id="aaa.dll" Source="..\..\OutPut\aaa.dll" />
    </Component>
    
  4. Now I would like to get the assemblies from the folder MyFolder which is an environment variable and append it to my Source

    <Directory Id="MyFolder" Name="MyFolder" SourceName="MyFolder">
      <Component Id="Component.bbb.exe" Guid="guid2">
        <File Id="bbb.exe" Name="bbb.exe" Vital="yes" Source=MyFolder + bbb.exe />
      </Component>
    </Directory>
    

I receive a compilation error saying it is unable to find bbb.exe.

Please let me know on where I'm going wrong.

like image 993
user873888 Avatar asked Apr 30 '26 17:04

user873888


1 Answers

See the Preprocessor documentation. I think you can simply do this to get bbb.exe from a path defined in an environment variable:

<File Id="bbb.exe" Name="bbb.exe" Vital="yes" Source="$(env.MyFolder)bbb.exe" />
like image 88
wimh Avatar answered May 03 '26 11:05

wimh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!