Skip to content

Commit

Permalink
Make the WiX dirs unique
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Nov 12, 2013
1 parent 98a9fa4 commit d98e8f1
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/app/FakeLib/WiXHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,32 @@ module Fake.WiXHelper

open System
open System.IO
open System.Collections.Generic

let mutable internal fileCount = 0
let mutable internal dirCount = 0

let mutable internal dirs = Dictionary()

let dirName dir =
match dirs.TryGetValue dir with
| true,n -> dirs.[dir] <- n+1; dir + n.ToString()
| _ -> dirs.[dir] <- 1; dir

let mutable internal compRefs = Dictionary()

let compRefName compRef =
match compRefs.TryGetValue compRef with
| true,n -> compRefs.[compRef] <- n+1; compRef + n.ToString()
| _ -> compRefs.[compRef] <- 1; compRef

let mutable internal comps = Dictionary()

let compName comp =
match comps.TryGetValue comp with
| true,n -> comps.[comp] <- n+1; comp + n.ToString()
| _ -> comps.[comp] <- 1; comp



/// Creates a WiX File tag from the given FileInfo
let wixFile (fileInfo:FileInfo) =
Expand All @@ -21,7 +44,6 @@ let getFilesAsWiXString files =

/// Creates recursive WiX directory and file tags from the given DirectoryInfo
let rec wixDir fileFilter asSubDir (directoryInfo:DirectoryInfo) =
dirCount <- dirCount + 1
let dirs =
directoryInfo
|> subDirectories
Expand All @@ -37,10 +59,10 @@ let rec wixDir fileFilter asSubDir (directoryInfo:DirectoryInfo) =

let compo =
if files = "" then "" else
sprintf "<Component Id=\"%s\" Guid=\"%s\">\r\n%s\r\n</Component>\r\n" directoryInfo.Name (Guid.NewGuid().ToString()) files
sprintf "<Component Id=\"%s\" Guid=\"%s\">\r\n%s\r\n</Component>\r\n" (compName directoryInfo.Name) (Guid.NewGuid().ToString()) files

if asSubDir then
sprintf "<Directory Id=\"di_%d\" Name=\"%s\">\r\n%s%s\r\n</Directory>\r\n" dirCount directoryInfo.Name dirs compo
sprintf "<Directory Id=\"%s\" Name=\"%s\">\r\n%s%s\r\n</Directory>\r\n" (dirName directoryInfo.Name) directoryInfo.Name dirs compo
else
sprintf "%s%s" dirs compo

Expand All @@ -52,7 +74,7 @@ let rec wixComponentRefs (directoryInfo:DirectoryInfo) =
|> Seq.map wixComponentRefs
|> toLines

if (filesInDir directoryInfo).Length > 0 then sprintf "%s<ComponentRef Id=\"%s\"/>\r\n" compos directoryInfo.Name else compos
if (filesInDir directoryInfo).Length > 0 then sprintf "%s<ComponentRef Id=\"%s\"/>\r\n" compos (compRefName directoryInfo.Name) else compos

open System

Expand Down

0 comments on commit d98e8f1

Please sign in to comment.