Add Component/@Shared and fix UninstallWhenSuperseded
Bob Arnson committed
May 14, 2019 at 14:19 UTC
44fb31d655bc5860d45e3acd4cd0cbfaaf5f12eb
6 files changed
+53
-12
src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
+2
-2
@@ -232,9 +232,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
232
attributes |= tuple.NeverOverwrite ? WindowsInstallerConstants.MsidbComponentAttributesNeverOverwrite : 0;
233
attributes |= tuple.Permanent ? WindowsInstallerConstants.MsidbComponentAttributesPermanent : 0;
234
attributes |= tuple.SharedDllRefCount ? WindowsInstallerConstants.MsidbComponentAttributesSharedDllRefCount : 0;
235
+ attributes |= tuple.Shared ? WindowsInstallerConstants.MsidbComponentAttributesShared : 0;
236
attributes |= tuple.Transitive ? WindowsInstallerConstants.MsidbComponentAttributesTransitive : 0;
236
- attributes |= tuple.UninstallWhenSuperseded ? WindowsInstallerConstants.MsidbComponentAttributes64bit : 0;
237
-
237
+ attributes |= tuple.UninstallWhenSuperseded ? WindowsInstallerConstants.MsidbComponentAttributesUninstallOnSupersedence : 0;
238
attributes |= tuple.Win64 ? WindowsInstallerConstants.MsidbComponentAttributes64bit : 0;
239
240
var table = output.EnsureTable(this.TableDefinitions["Component"]);
src/WixToolset.Core/Compiler.cs
+1
@@ -2469,6 +2469,7 @@ namespace WixToolset.Core
2469
NeverOverwrite = neverOverwrite,
2470
Permanent = permanent,
2471
SharedDllRefCount = sharedDllRefCount,
2472
+ Shared = shared,
2473
Transitive = transitive,
2474
UninstallWhenSuperseded = uninstallWhenSuperseded,
2475
Win64 = win64,
src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+38
-1
@@ -43,7 +43,7 @@ namespace WixToolsetTest.CoreIntegration
43
var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir"));
44
var section = intermediate.Sections.Single();
45
46
- var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
46
+ var wixFile = section.Tuples.OfType<WixFileTuple>().First();
47
Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
48
Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
49
}
@@ -539,6 +539,43 @@ namespace WixToolsetTest.CoreIntegration
539
}
540
}
541
542
+ [Fact]
543
+ public void CanBuildSharedComponent()
544
+ {
545
+ var folder = TestData.Get(@"TestData\SingleFile");
546
+
547
+ using (var fs = new DisposableFileSystem())
548
+ {
549
+ var baseFolder = fs.GetFolder();
550
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
551
+
552
+ var result = WixRunner.Execute(new[]
553
+ {
554
+ "build",
555
+ Path.Combine(folder, "Package.wxs"),
556
+ Path.Combine(folder, "PackageComponents.wxs"),
557
+ "-loc", Path.Combine(folder, "Package.en-us.wxl"),
558
+ "-bindpath", Path.Combine(folder, "data"),
559
+ "-intermediateFolder", intermediateFolder,
560
+ "-arch", "x64",
561
+ "-o", Path.Combine(baseFolder, @"bin\test.msi")
562
+ });
563
+
564
+ result.AssertSuccess();
565
+
566
+ var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir"));
567
+ var section = intermediate.Sections.Single();
568
+
569
+ // Only one component is shared.
570
+ var sharedComponentTuples = section.Tuples.OfType<ComponentTuple>();
571
+ Assert.Equal(1, sharedComponentTuples.Sum(t => t.Shared ? 1 : 0));
572
+
573
+ // And it is this one.
574
+ var sharedComponentTuple = sharedComponentTuples.Single(t => t.Id.Id == "Shared.dll");
575
+ Assert.True(sharedComponentTuple.Shared);
576
+ }
577
+ }
578
+
579
[Fact]
580
public void CanBuildSetProperty()
581
{
src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/PackageComponents.wxs
+10
-7
@@ -1,10 +1,13 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3
- <Fragment>
4
- <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
5
- <Component>
6
- <File Source="test.txt" />
7
- </Component>
8
- </ComponentGroup>
9
- </Fragment>
3
+ <Fragment>
4
+ <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
5
+ <Component>
6
+ <File Source="test.txt" />
7
+ </Component>
8
+ <Component Id="Shared.dll" Shared="yes">
9
+ <File Name="Shared.dll" Source="test.txt" />
10
+ </Component>
11
+ </ComponentGroup>
12
+ </Fragment>
13
</Wix>
src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs
+1
-1
@@ -50,7 +50,7 @@ namespace WixToolsetTest.CoreIntegration
50
var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir"));
51
var section = intermediate.Sections.Single();
52
53
- var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
53
+ var wixFile = section.Tuples.OfType<WixFileTuple>().First();
54
Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
55
Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
56
}
src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs
+1
-1
@@ -50,7 +50,7 @@ namespace WixToolsetTest.CoreIntegration
50
var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir"));
51
var section = intermediate.Sections.Single();
52
53
- var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
53
+ var wixFile = section.Tuples.OfType<WixFileTuple>().First();
54
Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
55
Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
56
}