Skip to content

Commit 05d57e7

Browse files
committed
Merge pull request #818 from DigitalFlow/feature/WiXHelperAddition
WiXHelper: Refactor wixDir function to improve major upgrade support
2 parents 792bff3 + 44799ae commit 05d57e7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/app/FakeLib/WiXHelper.fs

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ let getFilesAsWiXString files =
5353
|> toLines
5454

5555
/// Creates recursive WiX directory and file tags from the given DirectoryInfo
56+
/// The function will create one component for each file [best practice](https://support.microsoft.com/de-de/kb/290997/en-us)
57+
/// and set the GUID to "*", which will make WiX produce consistent Component Guids if the Component's target path doesn't change.
58+
/// This is vital for major upgrades, since windows installer needs a consistent component guid for tracking each of them.
59+
/// You can use the getComponentIdsFromWiXString function for getting all created component refs and adding them to features.
5660
let rec wixDir fileFilter asSubDir (directoryInfo : DirectoryInfo) =
5761
let dirs =
5862
directoryInfo
@@ -70,8 +74,9 @@ let rec wixDir fileFilter asSubDir (directoryInfo : DirectoryInfo) =
7074
let compo =
7175
if files = "" then ""
7276
else
73-
sprintf "<Component Id=\"%s\" Guid=\"%s\">\r\n%s\r\n</Component>\r\n" (compName directoryInfo.Name)
74-
(Guid.NewGuid().ToString()) files
77+
split '\n' files
78+
|> Seq.map(fun f -> sprintf "<Component Id=\"%s\" Guid=\"%s\">\r\n%s\r\n</Component>\r\n" (compName directoryInfo.Name) "*" f)
79+
|> toLines
7580

7681
if asSubDir then
7782
sprintf "<Directory Id=\"%s\" Name=\"%s\">\r\n%s%s\r\n</Directory>\r\n" (dirName directoryInfo.Name)

0 commit comments

Comments
 (0)