diff options
| author | Bob Arnson <bob@firegiant.com> | 2020-05-11 17:09:47 -0400 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2020-05-11 17:17:45 -0400 |
| commit | bac3d761d99fb7ae1012f3591baee2dbec115b28 (patch) | |
| tree | 852f30be8ba4b0bc4a2cbd3dfd703149f4d00d3d /src | |
| parent | 93d3a9e1f9cdc05456a612e238a83738cfd1750f (diff) | |
| download | wix-bac3d761d99fb7ae1012f3591baee2dbec115b28.tar.gz wix-bac3d761d99fb7ae1012f3591baee2dbec115b28.tar.bz2 wix-bac3d761d99fb7ae1012f3591baee2dbec115b28.zip | |
Fix named bind paths.
Diffstat (limited to 'src')
11 files changed, 134 insertions, 15 deletions
diff --git a/src/WixToolset.Core/Bind/FileResolver.cs b/src/WixToolset.Core/Bind/FileResolver.cs index b1676fad..6bc5a676 100644 --- a/src/WixToolset.Core/Bind/FileResolver.cs +++ b/src/WixToolset.Core/Bind/FileResolver.cs | |||
| @@ -115,7 +115,7 @@ namespace WixToolset.Core.Bind | |||
| 115 | } | 115 | } |
| 116 | else // not a rooted path so let's try applying all the different source resolution options. | 116 | else // not a rooted path so let's try applying all the different source resolution options. |
| 117 | { | 117 | { |
| 118 | string bindName = String.Empty; | 118 | string bindName = null; |
| 119 | var path = source; | 119 | var path = source; |
| 120 | string pathWithoutSourceDir = null; | 120 | string pathWithoutSourceDir = null; |
| 121 | 121 | ||
| @@ -138,25 +138,41 @@ namespace WixToolset.Core.Bind | |||
| 138 | 138 | ||
| 139 | foreach (var bindPath in bindPaths) | 139 | foreach (var bindPath in bindPaths) |
| 140 | { | 140 | { |
| 141 | if (!String.IsNullOrEmpty(pathWithoutSourceDir)) | 141 | if (!String.IsNullOrEmpty(bindName) && !String.IsNullOrEmpty(bindPath.Name)) |
| 142 | { | 142 | { |
| 143 | var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir); | 143 | if (String.Equals(bindName, bindPath.Name, StringComparison.OrdinalIgnoreCase) && String.IsNullOrEmpty(resolved)) |
| 144 | |||
| 145 | checkedPaths.Add(filePath); | ||
| 146 | if (CheckFileExists(filePath)) | ||
| 147 | { | 144 | { |
| 148 | resolved = filePath; | 145 | var filePath = Path.Combine(bindPath.Path, path); |
| 146 | |||
| 147 | checkedPaths.Add(filePath); | ||
| 148 | if (CheckFileExists(filePath)) | ||
| 149 | { | ||
| 150 | resolved = filePath; | ||
| 151 | } | ||
| 149 | } | 152 | } |
| 150 | } | 153 | } |
| 151 | 154 | else | |
| 152 | if (String.IsNullOrEmpty(resolved)) | ||
| 153 | { | 155 | { |
| 154 | var filePath = Path.Combine(bindPath.Path, path); | 156 | if (!String.IsNullOrEmpty(pathWithoutSourceDir)) |
| 157 | { | ||
| 158 | var filePath = Path.Combine(bindPath.Path, pathWithoutSourceDir); | ||
| 155 | 159 | ||
| 156 | checkedPaths.Add(filePath); | 160 | checkedPaths.Add(filePath); |
| 157 | if (CheckFileExists(filePath)) | 161 | if (CheckFileExists(filePath)) |
| 162 | { | ||
| 163 | resolved = filePath; | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | if (String.IsNullOrEmpty(resolved)) | ||
| 158 | { | 168 | { |
| 159 | resolved = filePath; | 169 | var filePath = Path.Combine(bindPath.Path, path); |
| 170 | |||
| 171 | checkedPaths.Add(filePath); | ||
| 172 | if (CheckFileExists(filePath)) | ||
| 173 | { | ||
| 174 | resolved = filePath; | ||
| 175 | } | ||
| 160 | } | 176 | } |
| 161 | } | 177 | } |
| 162 | } | 178 | } |
diff --git a/src/WixToolset.Core/CommandLine/CommandLine.cs b/src/WixToolset.Core/CommandLine/CommandLine.cs index 683d1f5a..79f5d5bc 100644 --- a/src/WixToolset.Core/CommandLine/CommandLine.cs +++ b/src/WixToolset.Core/CommandLine/CommandLine.cs | |||
| @@ -21,8 +21,6 @@ namespace WixToolset.Core.CommandLine | |||
| 21 | 21 | ||
| 22 | internal class CommandLine : ICommandLine | 22 | internal class CommandLine : ICommandLine |
| 23 | { | 23 | { |
| 24 | private static readonly char[] BindPathSplit = { '=' }; | ||
| 25 | |||
| 26 | public CommandLine(IWixToolsetServiceProvider serviceProvider) | 24 | public CommandLine(IWixToolsetServiceProvider serviceProvider) |
| 27 | { | 25 | { |
| 28 | this.ServiceProvider = serviceProvider; | 26 | this.ServiceProvider = serviceProvider; |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.en-us.wxl | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | |||
| 3 | <!-- | ||
| 4 | This file contains the declaration of all the localizable strings. | ||
| 5 | --> | ||
| 6 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
| 7 | |||
| 8 | <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String> | ||
| 9 | <String Id="FeatureTitle">MsiPackage</String> | ||
| 10 | |||
| 11 | </WixLocalization> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs new file mode 100644 index 00000000..85dcb695 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/Package.wxs | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 3 | <Product Id="*" Name="MsiPackage" Codepage="1252" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | ||
| 4 | <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" /> | ||
| 5 | |||
| 6 | <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> | ||
| 7 | <MediaTemplate /> | ||
| 8 | |||
| 9 | <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> | ||
| 10 | <ComponentGroupRef Id="ProductComponents" /> | ||
| 11 | </Feature> | ||
| 12 | </Product> | ||
| 13 | |||
| 14 | <Fragment> | ||
| 15 | <Directory Id="TARGETDIR" Name="SourceDir"> | ||
| 16 | <Directory Id="ProgramFilesFolder"> | ||
| 17 | <Directory Id="INSTALLFOLDER" Name="MsiPackage" /> | ||
| 18 | </Directory> | ||
| 19 | </Directory> | ||
| 20 | </Fragment> | ||
| 21 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs new file mode 100644 index 00000000..7d1a4ae1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/PackageComponents.wxs | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 3 | <Fragment> | ||
| 4 | <Binary Id="FooAlpha" SourceFile="!(bindpath.AlphaBits)foo.dll" /> | ||
| 5 | </Fragment> | ||
| 6 | |||
| 7 | <Fragment> | ||
| 8 | <Binary Id="FooMips" SourceFile="!(bindpath.MipsBits)foo.dll" /> | ||
| 9 | </Fragment> | ||
| 10 | |||
| 11 | <Fragment> | ||
| 12 | <Binary Id="FooPowerPC" SourceFile="!(bindpath.PowerBits)foo.dll" /> | ||
| 13 | </Fragment> | ||
| 14 | |||
| 15 | <Fragment> | ||
| 16 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
| 17 | <Component> | ||
| 18 | <File Source="test.txt" /> | ||
| 19 | </Component> | ||
| 20 | |||
| 21 | <Component Id="Shared.dll" Shared="yes"> | ||
| 22 | <File Name="Shared.dll" Source="test.txt" /> | ||
| 23 | </Component> | ||
| 24 | </ComponentGroup> | ||
| 25 | </Fragment> | ||
| 26 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/alpha/foo.dll | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/mips/foo.dll | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/powerpc/foo.dll | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/WixlibWithBinaries/data/test.txt | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 60cbde85..3989699d 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj | |||
| @@ -172,6 +172,13 @@ | |||
| 172 | <Content Include="TestData\Components\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | 172 | <Content Include="TestData\Components\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> |
| 173 | <Content Include="TestData\Components\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | 173 | <Content Include="TestData\Components\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 174 | <Content Include="TestData\Components\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> | 174 | <Content Include="TestData\Components\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 175 | <Content Include="TestData\WixlibWithBinaries\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
| 176 | <Content Include="TestData\WixlibWithBinaries\data\alpha\foo.dll" CopyToOutputDirectory="PreserveNewest" /> | ||
| 177 | <Content Include="TestData\WixlibWithBinaries\data\mips\foo.dll" CopyToOutputDirectory="PreserveNewest" /> | ||
| 178 | <Content Include="TestData\WixlibWithBinaries\data\powerpc\foo.dll" CopyToOutputDirectory="PreserveNewest" /> | ||
| 179 | <Content Include="TestData\WixlibWithBinaries\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | ||
| 180 | <Content Include="TestData\WixlibWithBinaries\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
| 181 | <Content Include="TestData\WixlibWithBinaries\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
| 175 | </ItemGroup> | 182 | </ItemGroup> |
| 176 | 183 | ||
| 177 | <ItemGroup> | 184 | <ItemGroup> |
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs index f63d1144..63771248 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs | |||
| @@ -53,6 +53,42 @@ namespace WixToolsetTest.CoreIntegration | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | [Fact] | 55 | [Fact] |
| 56 | public void CanBuildWixlibWithBinariesFromNamedBindPaths() | ||
| 57 | { | ||
| 58 | var folder = TestData.Get(@"TestData\WixlibWithBinaries"); | ||
| 59 | |||
| 60 | using (var fs = new DisposableFileSystem()) | ||
| 61 | { | ||
| 62 | var baseFolder = fs.GetFolder(); | ||
| 63 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 64 | var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); | ||
| 65 | |||
| 66 | var result = WixRunner.Execute(new[] | ||
| 67 | { | ||
| 68 | "build", | ||
| 69 | Path.Combine(folder, "PackageComponents.wxs"), | ||
| 70 | "-bf", | ||
| 71 | "-bindpath", Path.Combine(folder, "data"), | ||
| 72 | // Use names that aren't excluded in default .gitignores. | ||
| 73 | "-bindpath", $"AlphaBits={Path.Combine(folder, "data", "alpha")}", | ||
| 74 | "-bindpath", $"MipsBits={Path.Combine(folder, "data", "mips")}", | ||
| 75 | "-bindpath", $"PowerBits={Path.Combine(folder, "data", "powerpc")}", | ||
| 76 | "-intermediateFolder", intermediateFolder, | ||
| 77 | "-o", wixlibPath, | ||
| 78 | }); | ||
| 79 | |||
| 80 | result.AssertSuccess(); | ||
| 81 | |||
| 82 | var wixlib = Intermediate.Load(wixlibPath); | ||
| 83 | var binaryTuples = wixlib.Sections.SelectMany(s => s.Tuples).OfType<BinaryTuple>().ToList(); | ||
| 84 | Assert.Equal(3, binaryTuples.Count); | ||
| 85 | Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll")); | ||
| 86 | Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll-1")); | ||
| 87 | Assert.Single(binaryTuples.Where(t => t.Data.Path == "wix-ir/foo.dll-2")); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | [Fact] | ||
| 56 | public void CanBuildSingleFileUsingWixlib() | 92 | public void CanBuildSingleFileUsingWixlib() |
| 57 | { | 93 | { |
| 58 | var folder = TestData.Get(@"TestData\SingleFile"); | 94 | var folder = TestData.Get(@"TestData\SingleFile"); |
