Dendei
Dendei

Reputation: 571

WiX: how do i set a directory id as file source?

Hello i need to copy a file from a location the user specify how do i set it so i can use the directiory id?

something like this! (this wont work)

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="name" >

            <Component Id="id1" Guid="GUID">
                <File Name="dll.dll" DiskId="1" Vital="yes"
                      Source="[MYDIR]\dll.dll" />
            </Component>

        </Directory>
        <Directory Id="MYDIR" Name="mydirname" >
        </Directory>
    </Directory>
</Directory>

i have a browsedialog so i set the MYDIR but the user specify where i will find the file i want and then i want to use that path as source is this possible?

thank you for answers

EDIT

i put inside my INSTALLDIR

<CopyFile Id="dll.dll" 
SourceDirectory="MYDIR" 
SourceName="dll.dll" 
DestinationDirectory="INSTALLDIR" 
DestinationName="dll.dll" />

and worked fine :)

only problem with this is if the path is wrong and the file is not copied the installer runs anyway and i dont get my file :( so i have to validate the path somehow or do customaction to check if the file exists

anyway thanks for everything! :D

Upvotes: 1

Views: 1181

Answers (1)

Natalie Carr
Natalie Carr

Reputation: 3797

Yes it is possible, I think the CopyFile element is what you need:

<Component Id="MyComponent" Guid="YOUR_GUID">  
 <CopyFile Id="dll.dll" SourceProperty="[MYDIR]" SourceName="dll.dll" DestinationDirectory="INSTALLDIR" DestinationName="dll.dll" /> 
</Component>

Upvotes: 1

Related Questions