-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix code snippets; more Markdown, less HTML #231
Changes from 1 commit
dfd385f
ad3b05c
f50288a
7cd8328
3ffc5f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,33 @@ | ||
# How To: Reference another DirectorySearch element | ||
|
||
There may be times when you need to locate different files or subdirectories under the same directory, and assign each to a separate property. Since you cannot define the same DirectorySearch element more than once, you must use a DirectorySearchRef element. | ||
To reference another DirectorySearch element, you must specify the same Id, | ||
Parent Id, and Path attribute values or you will get unresolved symbol errors | ||
when linking with light.exe. | ||
There may be times when you need to locate different files or subdirectories under the same directory, and assign each to a separate property. Since you cannot define the same DirectorySearch element more than once, you must use a DirectorySearchRef element. To reference another DirectorySearch element, you must specify the same Id, Parent Id, and Path attribute values or you will get unresolved symbol errors when linking with light.exe. | ||
|
||
## Step 1: Define a DirectorySearch element | ||
|
||
You first need to define the parent DirectorySearch element. This is expected to | ||
contain the different files or subdirectories you will assign to separate | ||
properties. | ||
You first need to define the parent DirectorySearch element. This is expected to contain the different files or subdirectories you will assign to separate properties. | ||
|
||
``` | ||
<span style="COLOR: blue"><</span><span style="COLOR: #a31515">Property </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">SHDOCVW</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">WinDir</span>" <span style="COLOR: red">Path</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">[WindowsFolder]</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Media</span>" <span style="COLOR: red">Path</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Media</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">FileSearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Chimes</span>" <span style="COLOR: red">Name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">chimes.wav</span>" <span style="COLOR: blue">/> | ||
</</span><span style="COLOR: #a31515">DirectorySearch</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">DirectorySearch</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">Property</span><span style="COLOR: blue">></span> | ||
```xml | ||
<Property Id="SHDOCVW"> | ||
<DirectorySearch Id="WinDir" Path="[WindowsFolder]"> | ||
<DirectorySearch Id="Media" Path="Media"> | ||
<FileSearch Id="Chimes" Name="chimes.wav" /> | ||
</DirectorySearch> | ||
</DirectorySearch> | ||
</Property> | ||
``` | ||
|
||
This will search for the file "chimes.wav" under the Media directory in Windows. | ||
If the file is found, the full path will be assigned to the public property | ||
"SHDOCVW". | ||
This will search for the file "chimes.wav" under the Media directory in Windows. If the file is found, the full path will be assigned to the public property "SHDOCVW". | ||
|
||
## Step 2: Define a DirectorySearchRef element | ||
|
||
To search for another file in the Media directory, you need to reference all the | ||
same Id, Parent Id, and Path attributes. Because the Media DirectorySearch | ||
element is nested under the WinDir DirectorySearch element, its Parent attribute is automatically assigned the parent DirectorySearch element's Id attribute value; thus, that is what you must specify for the DirectorySearchRef element's Parent attribute value. | ||
To search for another file in the Media directory, you need to reference all the same Id, Parent Id, and Path attributes. Because the Media DirectorySearch element is nested under the WinDir DirectorySearch element, its Parent attribute is automatically assigned the parent DirectorySearch elements Id attribute value; thus, that is what you must specify for the DirectorySearchRef element's Parent attribute value. | ||
|
||
``` | ||
<span style="COLOR: blue"><</span><span style="COLOR: #a31515">Property </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">USER32</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearchRef </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Media</span>" <span style="COLOR: red">Parent</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">WinDir</span>" <span style="COLOR: red">Path</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Media</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">FileSearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Chord</span>" <span style="COLOR: red">Name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">chord.wav</span>" <span style="COLOR: blue">/> | ||
</</span><span style="COLOR: #a31515">DirectorySearchRef</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">Property</span><span style="COLOR: blue">></span> | ||
```xml | ||
<Property Id="USER32"> | ||
<DirectorySearchRef Id="Media" Parent="WinDir" Path="Media"> | ||
<FileSearch Id="Chord" Name="chord.wav" /> | ||
</DirectorySearchRef> | ||
</Property> | ||
``` | ||
|
||
If you wanted to refer to another DirectorySearch element that used the Id Media | ||
but was under a different parent path, you would have to define a new | ||
DirectorySearch element under a different parent than in step 1. | ||
If you wanted to refer to another DirectorySearch element that used the Id Media but was under a different parent path, you would have to define a new DirectorySearch element under a different parent than in step 1. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,31 @@ You can set a property to the parent directory of a file. | |
|
||
## Step 1: Define the search root | ||
|
||
In the following example, the path to [WindowsFolder]Microsoft.NET is defined as the root of the search. If you do not define a search root, Windows Installer will search all fixed drives up to the depth specified. | ||
In the following example, the path to \[WindowsFolder\]Microsoft.NET is defined as the root of the search. If you do not define a search root, Windows Installer will search all fixed drives up to the depth specified. | ||
|
||
``` | ||
<span style="COLOR: blue"><</span><span style="COLOR: #a31515">Property </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NGEN2DIR</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Windows</span>" <span style="COLOR: red">Path</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">[WindowsFolder]</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">MS.NET</span>" <span style="COLOR: red">Path</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Microsoft.NET</span>"<span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">DirectorySearch</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">DirectorySearch</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">Property</span><span style="COLOR: blue">></span> | ||
```xml | ||
<Property Id="NGEN2DIR"> | ||
<DirectorySearch Id="Windows" Path="[WindowsFolder]"> | ||
<DirectorySearch Id="MS.NET" Path="Microsoft.NET"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another indent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Corrected too. |
||
</DirectorySearch> | ||
</DirectorySearch> | ||
</Property> | ||
``` | ||
|
||
## Step 2: Define the parent directory to find | ||
Under the search root, define the directory you want returned and set the DirectorySearch/@AssignToProperty attribute to 'yes'. You must then define the file you want to find using a unique FileSearch/@Id attribute value. | ||
|
||
``` | ||
<span style="COLOR: blue"><</span><span style="COLOR: #a31515">Property </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NGEN2DIR</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Windows</span>" <span style="COLOR: red">Path</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">[WindowsFolder]</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">MS.NET</span>" <span style="COLOR: red">Path</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Microsoft.NET</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">DirectorySearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Ngen2Dir</span>" <span style="COLOR: red">Depth</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">2</span>" <span style="COLOR: red">AssignToProperty</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">yes</span>"<span style="COLOR: blue">> | ||
<</span><span style="COLOR: #a31515">FileSearch </span><span style="COLOR: red">Id</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Ngen_exe</span>" <span style="COLOR: red">Name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">ngen.exe</span>" <span style="COLOR: red">MinVersion</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">2.0.0.0</span>" <span style="COLOR: blue">/> | ||
</</span><span style="COLOR: #a31515">DirectorySearch</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">DirectorySearch</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">DirectorySearch</span><span style="COLOR: blue">> | ||
</</span><span style="COLOR: #a31515">Property</span><span style="COLOR: blue">></span> | ||
Under the search root, define the directory you want returned and set the DirectorySearch/@AssignToProperty attribute to 'yes'. You must then define the file you want to find using a unique FileSearch/@Id attribute value. | ||
|
||
```xml | ||
<Property Id="NGEN2DIR"> | ||
<DirectorySearch Id="Windows" Path="[WindowsFolder]"> | ||
<DirectorySearch Id="MS.NET" Path="Microsoft.NET"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Several indents here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just notice it's correctly rendered here: https://documentation.help/WiX/parentdirectorysearch.htm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
<DirectorySearch Id="Ngen2Dir" Depth="2" AssignToProperty="yes"> | ||
<FileSearch Id="Ngen_exe" Name="ngen.exe" MinVersion="2.0.0.0" /> | ||
</DirectorySearch> | ||
</DirectorySearch> | ||
</DirectorySearch> | ||
</Property> | ||
``` | ||
|
||
In this example, if ngen.exe is newer than version 2.0.0.0 and is found no more than two directories under [WindowsFolder]Microsoft.NET its parent directory is returned in the NGEN2DIR property. | ||
In this example, if ngen.exe is newer than version 2.0.0.0 and is found no more than two directories under \[WindowsFolder\]Microsoft.NET its parent directory is returned in the NGEN2DIR property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be indented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.