@@ -56,22 +56,36 @@ let getFilesAsWiXString files =
56
56
|> Seq.map ( fileInfo >> wixFile)
57
57
|> toLines
58
58
59
+ type Architecture =
60
+ | X64
61
+ | X86
62
+ override a.ToString () =
63
+ match a with
64
+ | X64 -> " x64"
65
+ | X86 -> " x86"
66
+
59
67
/// WiX File Element
60
68
type WiXFile =
61
69
{
70
+ /// File Id in WiX definition
62
71
Id : string
72
+ /// File Name in WiX definition
63
73
Name : string
74
+ /// File Path in WiX definition
64
75
Source : string
76
+ /// File Architecture, either X64 or X86, defaults to X64
77
+ ProcessorArchitecture : Architecture
65
78
}
66
- override w.ToString () = sprintf " <File Id=\" %s \" Name=\" %s \" Source=\" %s \" />"
67
- w.Id w.Name w.Source
79
+ override w.ToString () = sprintf " <File Id=\" %s \" Name=\" %s \" Source=\" %s \" ProcessorArchitecture= \" %s \" />"
80
+ w.Id w.Name w.Source ( w.ProcessorArchitecture.ToString ())
68
81
69
82
/// Defaults for WiX file
70
83
let WiXFileDefaults =
71
84
{
72
85
Id = " fi"
73
86
Name = " "
74
87
Source = " "
88
+ ProcessorArchitecture = X64
75
89
}
76
90
77
91
/// Specifies whether an action occur on install, uninstall or both.
@@ -349,12 +363,13 @@ and WiXComponent =
349
363
Id : string
350
364
Guid : string
351
365
Files : WiXFile seq
366
+ Win64 : YesOrNo
352
367
ServiceControls : WiXServiceControl seq
353
368
ServiceInstalls : WiXServiceInstall seq
354
369
}
355
370
member w.ToComponentRef () = generateComponentRef ( fun f -> { f with Id = w.Id })
356
- override w.ToString () = sprintf " <Component Id=\" %s \" Guid=\" %s \" >%s%s%s </Component>"
357
- w.Id w.Guid
371
+ override w.ToString () = sprintf " <Component Id=\" %s \" Guid=\" %s \" Win64= \" %s \" >%s%s%s </Component>"
372
+ w.Id w.Guid ( w.Win64.ToString ())
358
373
( Seq.fold( fun acc elem -> acc + elem.ToString()) " " w.Files)
359
374
( Seq.fold( fun acc elem -> acc + elem.ToString()) " " w.ServiceControls)
360
375
( Seq.fold( fun acc elem -> acc + elem.ToString()) " " w.ServiceInstalls)
@@ -399,6 +414,7 @@ let WiXComponentDefaults =
399
414
{
400
415
Id = " "
401
416
Guid = " *"
417
+ Win64 = Yes
402
418
Files = []
403
419
ServiceControls = []
404
420
ServiceInstalls = []
@@ -411,9 +427,6 @@ let generateComponent (setParams : WiXComponent -> WiXComponent) =
411
427
failwith " No parameter passed for component Id!"
412
428
parameters
413
429
414
-
415
-
416
-
417
430
/// Defaults for directories
418
431
let WiXDirDefaults =
419
432
{
@@ -443,8 +456,13 @@ let private getDirectoryId (directoryName : string) =
443
456
444
457
let private getFileId ( fileName : string ) =
445
458
" f" + calcSHA1 fileName
459
+
460
+ let private IsWin64 architecture =
461
+ match architecture with
462
+ | X64 -> Yes
463
+ | X86 -> No
446
464
447
- let private createComponents fileFilter directoryInfo directoryName =
465
+ let private createComponents fileFilter directoryInfo directoryName architecture =
448
466
directoryInfo
449
467
|> filesInDir
450
468
|> Seq.filter fileFilter
@@ -453,11 +471,13 @@ let private createComponents fileFilter directoryInfo directoryName =
453
471
Id = getFileId ( directoryName + directoryInfo.Name + file.Name)
454
472
Name = file.Name
455
473
Source = file.FullName
474
+ ProcessorArchitecture = architecture
456
475
})
457
476
|> Seq.map( fun file ->
458
477
C{
459
478
Id = " c" + file.Id.Substring( 1 )
460
479
Guid = " *"
480
+ Win64 = IsWin64 architecture
461
481
Files = [ file]
462
482
ServiceControls = []
463
483
ServiceInstalls = []
@@ -469,20 +489,20 @@ let private createComponents fileFilter directoryInfo directoryName =
469
489
/// This is vital for major upgrades, since windows installer needs a consistent component guid for tracking each of them.
470
490
/// You can use the getComponentRefs function for getting all created component refs and adding them to features.
471
491
/// You can use attachServiceControlToComponents or attachServiceInstallToComponents to attach ServiceControl or ServiceInstall to the directory component hierarchy
472
- let rec bulkComponentTreeCreation fileFilter directoryFilter directoryInfo =
492
+ let rec bulkComponentTreeCreation fileFilter directoryFilter directoryInfo architecture =
473
493
let directoryName = " "
474
494
let directories = directoryInfo
475
495
|> subDirectories
476
496
|> Seq.filter directoryFilter
477
- |> Seq.map ( fun d -> bulkComponentTreeSubCreation fileFilter directoryFilter d directoryInfo.Name)
478
- let components = createComponents fileFilter directoryInfo directoryName
497
+ |> Seq.map ( fun d -> bulkComponentTreeSubCreation fileFilter directoryFilter d directoryInfo.Name architecture )
498
+ let components = createComponents fileFilter directoryInfo directoryName architecture
479
499
Seq.append directories components
480
- and private bulkComponentTreeSubCreation fileFilter directoryFilter directoryInfo directoryName =
500
+ and private bulkComponentTreeSubCreation fileFilter directoryFilter directoryInfo directoryName architecture =
481
501
let directories = directoryInfo
482
502
|> subDirectories
483
503
|> Seq.filter directoryFilter
484
- |> Seq.map ( fun d -> bulkComponentTreeSubCreation fileFilter directoryFilter d ( directoryName + directoryInfo.Name))
485
- let components = createComponents fileFilter directoryInfo directoryName
504
+ |> Seq.map ( fun d -> bulkComponentTreeSubCreation fileFilter directoryFilter d ( directoryName + directoryInfo.Name) architecture )
505
+ let components = createComponents fileFilter directoryInfo directoryName architecture
486
506
let currentDirectory = D{
487
507
Id = getDirectoryId ( directoryInfo.Name + directoryName)
488
508
Name = directoryInfo.Name
@@ -496,7 +516,7 @@ and private bulkComponentTreeSubCreation fileFilter directoryFilter directoryInf
496
516
/// and set the GUID to "*", which will make WiX produce consistent Component Guids if the Component's target path doesn't change.
497
517
/// This is vital for major upgrades, since windows installer needs a consistent component guid for tracking each of them.
498
518
/// You can use the getComponentIdsFromWiXString function for getting all created component refs and adding them to features.
499
- let bulkComponentCreation fileFilter directoryInfo =
519
+ let bulkComponentCreation fileFilter directoryInfo architecture =
500
520
directoryInfo
501
521
|> filesInDir
502
522
|> Seq.filter fileFilter
@@ -505,11 +525,13 @@ let bulkComponentCreation fileFilter directoryInfo =
505
525
Id = " f" + file.Name.GetHashCode() .ToString() .Replace( " -" , " " )
506
526
Name = file.Name
507
527
Source = file.FullName
528
+ ProcessorArchitecture = architecture
508
529
})
509
530
|> Seq.map( fun file ->
510
531
C{
511
532
Id = " c" + file.Id.Substring( 1 )
512
533
Guid = " *"
534
+ Win64 = IsWin64 architecture
513
535
Files = [ file]
514
536
ServiceControls = []
515
537
ServiceInstalls = []
@@ -520,19 +542,19 @@ let bulkComponentCreation fileFilter directoryInfo =
520
542
/// and set the GUID to "*", which will make WiX produce consistent Component Guids if the Component's target path doesn't change.
521
543
/// This is vital for major upgrades, since windows installer needs a consistent component guid for tracking each of them.
522
544
/// The components are embedded into the passed in root directory.
523
- let bulkComponentCreationAsSubDir fileFilter ( directoryInfo : DirectoryInfo ) =
545
+ let bulkComponentCreationAsSubDir fileFilter ( directoryInfo : DirectoryInfo ) architecture =
524
546
{
525
547
Id = ( directoryInfo.FullName.GetHashCode() .ToString())
526
548
Name = directoryInfo.Name
527
549
Files = []
528
- Components = bulkComponentCreation fileFilter directoryInfo
550
+ Components = bulkComponentCreation fileFilter directoryInfo architecture
529
551
}
530
552
531
553
///// Use this to attach service controls to your components.
532
554
let rec attachServiceControlToComponent ( comp : WiXDirectoryComponent ) fileFilter serviceControls =
533
555
match comp with
534
556
| C c -> C ( if fileFilter c then
535
- { Id = c.Id; Guid = c.Guid; Files = c.Files; ServiceControls = Seq.append c.ServiceControls serviceControls; ServiceInstalls = c.ServiceInstalls }
557
+ { Id = c.Id; Guid = c.Guid; Files = c.Files; ServiceControls = Seq.append c.ServiceControls serviceControls; ServiceInstalls = c.ServiceInstalls; Win64 = c.Win64 }
536
558
else
537
559
c
538
560
)
@@ -545,7 +567,7 @@ and attachServiceControlToComponents (components : WiXDirectoryComponent seq) fi
545
567
let rec attachServiceInstallToComponent ( comp : WiXDirectoryComponent ) fileFilter serviceInstalls =
546
568
match comp with
547
569
| C c -> C ( if fileFilter c then
548
- { Id = c.Id; Guid = c.Guid; Files = c.Files; ServiceControls = c.ServiceControls; ServiceInstalls = Seq.append c.ServiceInstalls serviceInstalls }
570
+ { Id = c.Id; Guid = c.Guid; Files = c.Files; ServiceControls = c.ServiceControls; ServiceInstalls = Seq.append c.ServiceInstalls serviceInstalls; Win64 = c.Win64 }
549
571
else
550
572
c
551
573
)
@@ -833,6 +855,9 @@ type WiXScript =
833
855
834
856
/// You can nest InstallExecuteSequence actions in here
835
857
ActionSequences : string
858
+
859
+ /// Specify architecture of package. For 64Bit Setups set ProgramFilesFolder to ProgramFiles64, package platform to X64, all components to Win64 = yes and all files' processorArchitecture to X64.
860
+ Platform : Architecture
836
861
}
837
862
838
863
/// Default values for WiX Script properties
@@ -856,6 +881,7 @@ let WiXScriptDefaults =
856
881
Features = " "
857
882
CustomActions = " "
858
883
ActionSequences = " "
884
+ Platform = X86
859
885
}
860
886
861
887
/// Used in WiXCustomAction for determing when to run the custom action
@@ -1171,6 +1197,9 @@ type Script =
1171
1197
1172
1198
/// You can add custom replacements for the wix xml here.
1173
1199
CustomReplacements: ( string * string ) seq
1200
+
1201
+ /// Specify architecture of package. For 64Bit Setups set ProgramFilesFolder to ProgramFiles64, package platform to X64, all components to Win64 = yes and all files' processorArchitecture to X64.
1202
+ Platform : Architecture
1174
1203
}
1175
1204
1176
1205
/// Default values for WiX Script properties
@@ -1195,6 +1224,7 @@ let ScriptDefaults =
1195
1224
CustomActions = []
1196
1225
ActionSequences = []
1197
1226
CustomReplacements = []
1227
+ Platform = Architecture.X64
1198
1228
}
1199
1229
1200
1230
/// Generates WiX Template with specified file name (you can prepend location too)
@@ -1225,6 +1255,7 @@ let generateWiXScript fileName =
1225
1255
Id=\" *\"
1226
1256
InstallerVersion=\" 200\"
1227
1257
Compressed=\" yes\"
1258
+ Platform=\" @Product.Platform@\"
1228
1259
Description=\" @Product.Description@\"
1229
1260
Manufacturer=\" @Product.Publisher@\"
1230
1261
/>
@@ -1306,6 +1337,7 @@ let FillInWixScript wiXPath (setParams : WiXScript -> WiXScript) =
1306
1337
" @Product.MajorUpgrade@" , parameters.MajorUpgrade
1307
1338
" @Product.Directories@" , parameters.Directories
1308
1339
" @Product.Components@" , " "
1340
+ " @Product.Platform@" , parameters.Platform.ToString()
1309
1341
" @Product.Features@" , parameters.Features
1310
1342
" @Product.CustomActions@" , parameters.CustomActions
1311
1343
" @Product.ActionSequences@" , parameters.ActionSequences
@@ -1356,6 +1388,7 @@ let FillInWiXTemplate wiXPath setParams =
1356
1388
" @Product.Features@" , Seq.fold( fun acc elem -> acc + elem.ToString()) " " parameters.Features
1357
1389
" @Product.CustomActions@" , Seq.fold( fun acc elem -> acc + elem.ToString()) " " parameters.CustomActions
1358
1390
" @Product.ActionSequences@" , Seq.fold( fun acc elem -> acc + elem.ToString()) " " parameters.ActionSequences
1391
+ " @Product.Platform@" , parameters.Platform.ToString()
1359
1392
" @Build.number@" , parameters.BuildNumber]
1360
1393
let customReplacements = parameters.CustomReplacements |> Seq.map ( fun ( key , value ) -> (( sprintf " @Custom.%s @" key), value)) |> List.ofSeq
1361
1394
let replacements = replacements @ customReplacements
0 commit comments