2010-01-25 12 views
18

Sono nuovo di WiX. Molto nuovo. C'è un modo per definire contemporaneamente un ComponentGroup e una Directory?In Wix, si può definire un ComponentGroup e una Directory allo stesso tempo?

Ho un numero elevato di file, dell'ordine di circa 300 totali, che devono essere suddivisi in un numero di gruppi, con ogni gruppo con circa 50 file.

Utilizzando heat.exe, sono stato in grado di creare un frammento che crea componenti per ogni file. Vorrei evitare di dover ri-elencare ognuno di questi componenti in una definizione di ComponentGroup separata. Mi piacerebbe essere in grado di avvolgere l'elenco dei componenti generati da calore in una definizione di ComponentGroup, quindi semplicemente utilizzare ComponentGroupRef all'interno di una struttura DirectoryRef.

Spero che questo chiarisca. Attualmente devo fare:

<DirectoryRef Id="FilesDir"> 
    <Component Id="a.txt" Guid="YOUR-GUID"> 
    <File Id="a.txt" KeyPath="yes" Source="SourceDir\a.txt" /> 
    </Component> 
    <Component Id="b.txt" Guid="YOUR-GUID"> 
    <File Id="b.txt" KeyPath="yes" Source="SourceDir\b.txt" /> 
    </Component> 
... 
    <Component Id="z.txt" Guid="YOUR-GUID"> 
    <File Id="z.txt" KeyPath="yes" Source="SourceDir\z.txt" /> 
    </Component> 
</DirectoryRef> 

<ComponentGroup Id="FilesGroup"> 
    <ComponentRef Id="a.txt"> 
    <ComponentRef Id="b.txt"> 
... 
    <ComponentRef Id="z.txt"> 
</ComponentGroup> 

Devo elencare ogni file due volte. Quello puzza.

mi piacerebbe essere in grado di fare:

<ComponentGroup Id="FilesGroup"> 
    <Component Id="a.txt" Guid="YOUR-GUID"> 
    <File Id="a.txt" KeyPath="yes" Source="SourceDir\a.txt" /> 
    </Component> 
    <Component Id="b.txt" Guid="YOUR-GUID"> 
    <File Id="b.txt" KeyPath="yes" Source="SourceDir\b.txt" /> 
    </Component> 
... 
    <Component Id="z.txt" Guid="YOUR-GUID"> 
    <File Id="z.txt" KeyPath="yes" Source="SourceDir\z.txt" /> 
    </Component> 
</ComponentGroup> 

<DirectoryRef Id="FilesDir"> 
    <ComponentGroupRef Id="FilesGroup"> 
</DirectoryRef> 

è possibile? C'è un altro modo per renderlo più facile che non vedo?

Aggiornamento: Abbiamo abbandonato Wix e quindi non sono sicuro di dover contrassegnare una soluzione oppure no. Se qualcuno sente che una delle risposte di seguito è la risposta alla mia domanda ora piuttosto vecchia, fammi sapere, e segnerò la risposta appropriata in quanto tale.

risposta

7

Spero di capire la tua domanda corretta. Sto usando lo strumento di calore su ogni build per generare automaticamente wx contenenti componenti che mirano al contenuto della directory di output della build. Il WXS (dopo la semplificazione) si presenta così:

<?xml version="1.0" encoding="utf-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Fragment> 
     <ComponentGroup Id="CompGroup01"> 
      <Component Id="cmp1D6110E9A0B9E351095F414BEB4D2E35" Directory="Dir01" Guid="*"> 
       <File Id="fil53541B947C7CE0A96A604898F1B825C5" KeyPath="yes" Source="$(var.HarvestDir)\somefile.exe" /> 
      </Component> 
     </ComponentGroup> 
    </Fragment> 
</Wix> 

nelle Product.wxs ho questo link hardcode al codice generato automaticamente:

<Directory Id="TARGETDIR" Name="SourceDir"> 
    <Directory Id="ProgramFilesFolder" Name="PFiles"> 
     <Directory Id="INSTALLDIR" Name="myInstallDir"> 
     <Directory Id="Dir01" Name="myInstallSubDir" /> 
     </Directory> 
    </Directory> 
</Directory> 

<Feature Id="ProductFeature" Title="MyProductComplete" Level="1"> 
    <ComponentGroupRef Id="CompGroup01" /> 
</Feature> 

Nel file di wixproj c'è un "raccolto-task" definito (non è assolutamente pulito, ma funziona). Il wixproj non è completo, ho cancellato tutte le parti irrilevanti:

<PropertyGroup> 
    <!-- relative path to directory from which setup will load input files --> 
    <MyWixSourceDir>C:\bin</MyWixSourceDir> 
    <!-- relative path to directory where inputs will be temporarily copied during harvesting --> 
    <MyWixHarvestDir>tempHarvest</MyWixHarvestDir> 
    <DefineConstants>Debug;HarvestDirApp=$(ProjectDir)$(MyWixHarvestDir)</DefineConstants> 
</PropertyGroup> 
<ItemGroup> 
    <!-- defines item group containing files which represent automatically harvested input for our WiX setup --> 
    <SetupInputFiles Include="$(MyWixSourceDir)\**\*.*" /> 
</ItemGroup> 
<ItemGroup> 
    <!-- defines item group of autogenerated files --> 
    <AutoGeneratedFiles Include="*.autogenerated.wxs" /> 
</ItemGroup> 
<Target Name="BeforeBuild"> 
    <!-- 1) prepare harvesting --> 
    <!-- remove temporary harvesting directory in case previous build did not cleaned up its temp files and folders --> 
    <RemoveDir Directories="$(ProjectDir)$(MyWixHarvestDir)" /> 
    <!-- delete old autogenerated files first --> 
    <Delete Files="@(AutoGeneratedFiles)" ContinueOnError="false" /> 
    <!-- 2) harvest application build output --> 
    <!-- copies input files into temporary directory so that they can be harvested into WXS file --> 
    <Copy SourceFiles="@(SetupInputFiles)" DestinationFiles="@(SetupInputFiles->'$(ProjectDir)$(MyWixHarvestDir)\%(RecursiveDir)%(Filename)%(Extension)')" ContinueOnError="false" /> 
    <!-- harvest files and produce WXS file defining all file and directory components for the setup --> 
    <Exec Command="&quot;$(WixExtDir)heat&quot; dir $(ProjectDir)$(MyWixHarvestDir) -dr Dir01 -sreg -srd -ag -cg CompGroup01 -var var.HarvestDirApp -out InstallDirApp.autogenerated.wxs" ContinueOnError="false" WorkingDirectory="." /> 
</Target> 
<Target Name="AfterBuild"> 
    <!-- 4) clean-up: remove temporary harvesting directory --> 
    <RemoveDir Directories="$(ProjectDir)$(KbcWixHarvestDir)" /> 
</Target> 

più importante è l'elemento Exec che esegue la raccolta. Io uso "-dr Dir01" per definire che i componenti faranno riferimento a "Dir01" come directory principale e "-cg ComGroup01" per definire il componenteGroup.

3
$ heat dir your_dir -gg -sfrag -cg ComponentGroupName -o myout.wxs 

Utilizzare il flag -h o la descrizione delle opzioni.

Questo ti darà un singolo ComponentGroup ID che puoi collegare alla funzione desiderata.

Problemi correlati