简体   繁体   中英

How do I copy all the files from source folder without specifying filenames in WIX installer configurations

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.

Update

Issue Resolved by auto generating the component file

      <HeatDirectory OutputFile="ComponentsGenerated.wxs" 
               DirectoryRefId="INSTALLFOLDER" 
               Transforms="Filter.xslt" 
               ComponentGroupName="PublishedComponents" 
               SuppressCom="true" 
               Directory="..\..\Service\bin\$(Configuration)\netcoreapp2.1\win-$(Platform)\publish" 
               SuppressFragments="true" SuppressRegistry="true" 
               SuppressRootDirectory="true" 
               AutoGenerateGuids="false" 
               GenerateGuidsNow="true" 
               ToolPath="$(WixToolPath)" 
               PreprocessorVariable="var.BasePath" />

Bonus

Since I had to install and run the windows service, I have used Transforms methods to remove the EXE generated in component WXS file.

I am loving Wix now!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM