1

Here is the WXS file content for copying the individual files

      <Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="MergeRedirectFolder">
    <Component Id="owcF3EB3D7C133F5B48E5859309ABDC2EE0" Guid="5a6040ae-b91e-47b6-8438-d9cd47fb947a">
      <File Id="owfF3EB3D7C133F5B48E5859309ABDC2EE0" 
     Source="$(var.SourceDir)\api-ms-win-core-console-l1-1-0.dll" KeyPath="yes" />
    </Component>
    <Component Id="owcB0E3C7251F136710A0F11E0C18525364" Guid="f80e6202-0436-d488-52cf-827e37483096">
      <File Id="owfB0E3C7251F136710A0F11E0C18525364" 
      Source="$(var.SourceDir)\api-ms-win-core-datetime-l1-1-0.dll" KeyPath="yes" />
    </Component>
    <Component Id="owc4B0AD9DF281D253C1207D4E82DEB0DD2" Guid="4ac4edbd-2c6a-8aed-125e-11237a36e4f8">
     <File Id="owf0E5D53A7E23AE08AF9D984ADC41AC589"

     Source="$(var.SourceDir)\publish\sos_amd64_amd64_4.6.26628.05.dll" KeyPath="yes" />

I have defined my source directory as follow

    <?define SourceDir="..\..\Services\bin\Debug\netcoreapp2.1\win7-x64\"?>

How can I specify WIX to copy all files instead of specifying one in each line?

Why?

My publish output files having different versions in different machines, so i do not want to hard code file versions in WIX configurations.

Publish folder has below files depend on the system it got published

In Dev machine, I have file sos_amd64_amd64_4.6.26725.06

In Build machine, I have file sos_amd64_amd64_4.6.26725.05

If you see the, the version is different in above files. So Wix build is failing due to mismatched version in *.wxs file. So I want to read all files from folder, rather than specifying individual files.

double-beep
  • 5,031
  • 17
  • 33
  • 41
kudlatiger
  • 3,028
  • 8
  • 48
  • 98

2 Answers2

2

I can see from the authoring that you are using IsWiX (disclaimer: I'm the author). IsWiX was designed to only support static authoring not the kind of authoring that you are trying to do. I've blogged many times on why I feel that's the better safer to do but telling that story on Stack Overflow doesn't usually go over well.

That said, IsWiX will not prevent you from doing what you are trying to do. Generally what I recommend doing is:

In your main setup project in the Code folder create a new wxs fragment called "HarvestedComponents.wxs"

Commit this empty file to source control and add it to your .gitignore if using Git.

Put the following in the prebuild step of the project

C:\Program Files (x86)\WiX Toolset v3.11\bin\heat.exe" dir "$(SolutionDir)Deploy\Path-To-Some-Directory-To-Harvest" -dr INSTALLLOCATION -cg HarvestedComponents -gg -g1 -sf -srd -scom -sreg -ke -var "var.Deploy" -out "$(SolutionDir)ClientTools\Code\harvestedcomponents.wxs

You'll have to tweak that a little to match your desired directory structure in Features.wxs.

Build the project and notice the HarvestedComponents.wxs get data. You don't want to commit this to source control but it shouldn't hurt if you do. I wouldn't.

Now to wire these harvested components up to your installer you need to edit Code\Features.wxs. Add:

<ComponentGroupRef Id="HarvestedComponents" />

to the feature that you want these components associated with.

The final MSI will now dynamically author these folders/files into the MSI along with whatever you statically define in the mege module wxs using IsWiX.

Note: Please be aware that there are trade offs with this approach. Mainly:

http://blog.iswix.com/2007/06/dealing-with-very-large-number-of-files.html

I also wonder why your sos artifact is version 06 on the dev box and version 05 on the build box. How often does this change? If this is simply a version mismactch and the artifact rarely changes then you may be solving the wrong problem. If the version is deisgned to be controlled by the build environment and changes frequently and the folder names and file names change from version to version then this might be the right solution for your needs.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • 1
    PS- If this all works for you, I invite you to submit a pull request to document this in https://github.com/iswix-llc/iswix-tutorials – Christopher Painter Sep 07 '18 at 15:03
  • Let me try the steps you specified, and if it works definitely submit a pull request in git documents. – kudlatiger Sep 08 '18 at 07:58
  • sos artifact version always generates 05 on build machine. I feel deleting itself to resolve the blocker but worried that my self contained .net core application might not work post that. – kudlatiger Sep 08 '18 at 07:58
  • 1
    I find myself sitting around on a rainy saturday morning with nothing to do. Let me know if you need any help. If you do decide to write a tutorial, I would suggest that things like NodeJS, NPM, WebDevelopment where the content is thousands of files and there is no value in the developer micromanaging this. It is not reccomended for the run of the mill I have an EXE, a few DLLs and some config files type situtation. That is best served by the developer analyizing his dependences / application foot print and authoring statically using the Files and Folders designer. – Christopher Painter Sep 08 '18 at 12:41
  • HarvestedComponents is regenrating every time and it looses my changes. I have added 'ServiceInstall' details which are getting over written. so how do I install and start my windows service ? – kudlatiger Sep 10 '18 at 09:01
  • 1
    I still feel the root issue of artifact versions should be understood and resolved. It's strange you'd have one version in your dev environment and a different version in your prod (build/installer) environment. They should be the same. If they were you wouldn't need all of this complexity and risk. Let's say all of a sudden tomorrow the build environment brings in 6? Is it really a good thing the installer just packages it up and goes about it's way? Wouldn't you want to know? That's the fundamental problem with "autopilot".. it's a good thing until it isn't. – Christopher Painter Sep 10 '18 at 11:32
  • 1
    I sometimes have people come to me thinking installers are simple to author because they are simple to install. "Oh I just want to deploy all the files in this directory" followed up with "but not those files, these files go with this feature and these files with that feature oh and this EXE needs a shortcut and that EXE needs a service and so on and so on". Someone bent on the dynamic path then goes down the transformation path because it feels like a problem to be solved with code. I could create a template for this but I feel my current templates and explicit static authoring are best. – Christopher Painter Sep 10 '18 at 11:37
  • I totally agree with you. Root cause still need to be resolved and I am working on it. I will keep you posted. I think it's time to contribute to https://github.com/iswix-llc/iswix-tutorials – kudlatiger Sep 11 '18 at 03:33
  • Cool. Pull requests are easily accepted. No drama. – Christopher Painter Sep 11 '18 at 05:21
0

You could try the harvesting tool heat. Here is the documentation

For Wix 3: https://wixtoolset.org/docs/v3/overview/heat/

For Wix 4: https://wixtoolset.org/docs/reference/heat/

Philipp
  • 26
  • 4
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33891151) – Markus Meyer Feb 26 '23 at 07:13