diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-07-31 15:29:40 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-07-31 15:29:40 -0700 |
| commit | 79473d778b6cc4c8eec93b92e3b244aed904dac1 (patch) | |
| tree | 9b0ee8c776c10e59e4578d34ce66e54957d5a436 /src | |
| parent | f1cb7b29489d795781895727e2bab4f734b57351 (diff) | |
| download | wix-79473d778b6cc4c8eec93b92e3b244aed904dac1.tar.gz wix-79473d778b6cc4c8eec93b92e3b244aed904dac1.tar.bz2 wix-79473d778b6cc4c8eec93b92e3b244aed904dac1.zip | |
Support build of a .wixipl to final output
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Core/Binder.cs | 1 | ||||
| -rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 72 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs | 89 |
3 files changed, 138 insertions, 24 deletions
diff --git a/src/WixToolset.Core/Binder.cs b/src/WixToolset.Core/Binder.cs index 23f1ba21..2a40ce71 100644 --- a/src/WixToolset.Core/Binder.cs +++ b/src/WixToolset.Core/Binder.cs | |||
| @@ -8,7 +8,6 @@ namespace WixToolset.Core | |||
| 8 | using System.Linq; | 8 | using System.Linq; |
| 9 | using System.Reflection; | 9 | using System.Reflection; |
| 10 | using WixToolset.Data; | 10 | using WixToolset.Data; |
| 11 | using WixToolset.Data.Bind; | ||
| 12 | using WixToolset.Data.Tuples; | 11 | using WixToolset.Data.Tuples; |
| 13 | using WixToolset.Extensibility; | 12 | using WixToolset.Extensibility; |
| 14 | using WixToolset.Extensibility.Data; | 13 | using WixToolset.Extensibility.Data; |
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index d8327b7a..822c4a9a 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
| @@ -74,17 +74,16 @@ namespace WixToolset.Core.CommandLine | |||
| 74 | 74 | ||
| 75 | public int Execute() | 75 | public int Execute() |
| 76 | { | 76 | { |
| 77 | var wixobjs = this.CompilePhase(); | 77 | var creator = this.ServiceProvider.GetService<ITupleDefinitionCreator>(); |
| 78 | |||
| 79 | this.EvaluateSourceFiles(creator, out var codeFiles, out var wixipl); | ||
| 78 | 80 | ||
| 79 | if (this.Messaging.EncounteredError) | 81 | if (this.Messaging.EncounteredError) |
| 80 | { | 82 | { |
| 81 | return this.Messaging.LastErrorNumber; | 83 | return this.Messaging.LastErrorNumber; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 84 | if (!wixobjs.Any()) | 86 | var wixobjs = this.CompilePhase(codeFiles); |
| 85 | { | ||
| 86 | return 1; | ||
| 87 | } | ||
| 88 | 87 | ||
| 89 | var wxls = this.LoadLocalizationFiles().ToList(); | 88 | var wxls = this.LoadLocalizationFiles().ToList(); |
| 90 | 89 | ||
| @@ -104,7 +103,10 @@ namespace WixToolset.Core.CommandLine | |||
| 104 | } | 103 | } |
| 105 | else | 104 | else |
| 106 | { | 105 | { |
| 107 | var wixipl = this.LinkPhase(wixobjs); | 106 | if (wixipl == null) |
| 107 | { | ||
| 108 | wixipl = this.LinkPhase(wixobjs, creator); | ||
| 109 | } | ||
| 108 | 110 | ||
| 109 | if (!this.Messaging.EncounteredError) | 111 | if (!this.Messaging.EncounteredError) |
| 110 | { | 112 | { |
| @@ -122,12 +124,50 @@ namespace WixToolset.Core.CommandLine | |||
| 122 | return this.Messaging.LastErrorNumber; | 124 | return this.Messaging.LastErrorNumber; |
| 123 | } | 125 | } |
| 124 | 126 | ||
| 125 | private IEnumerable<Intermediate> CompilePhase() | 127 | private void EvaluateSourceFiles(ITupleDefinitionCreator creator, out List<SourceFile> codeFiles, out Intermediate wixipl) |
| 126 | { | 128 | { |
| 127 | var intermediates = new List<Intermediate>(); | 129 | codeFiles = new List<SourceFile>(); |
| 130 | |||
| 131 | wixipl = null; | ||
| 128 | 132 | ||
| 129 | foreach (var sourceFile in this.SourceFiles) | 133 | foreach (var sourceFile in this.SourceFiles) |
| 130 | { | 134 | { |
| 135 | var extension = Path.GetExtension(sourceFile.SourcePath); | ||
| 136 | |||
| 137 | if (wixipl != null || ".wxs".Equals(extension, StringComparison.OrdinalIgnoreCase)) | ||
| 138 | { | ||
| 139 | codeFiles.Add(sourceFile); | ||
| 140 | } | ||
| 141 | else | ||
| 142 | { | ||
| 143 | try | ||
| 144 | { | ||
| 145 | wixipl = Intermediate.Load(sourceFile.SourcePath, creator); | ||
| 146 | } | ||
| 147 | catch (WixException) | ||
| 148 | { | ||
| 149 | // We'll assume anything that isn't a valid intermediate is source code to compile. | ||
| 150 | codeFiles.Add(sourceFile); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | } | ||
| 154 | |||
| 155 | if (wixipl == null && codeFiles.Count == 0) | ||
| 156 | { | ||
| 157 | this.Messaging.Write(ErrorMessages.NoSourceFiles()); | ||
| 158 | } | ||
| 159 | else if (wixipl != null && codeFiles.Count != 0) | ||
| 160 | { | ||
| 161 | this.Messaging.Write(ErrorMessages.WixiplSourceFileIsExclusive()); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | private IEnumerable<Intermediate> CompilePhase(IEnumerable<SourceFile> sourceFiles) | ||
| 166 | { | ||
| 167 | var intermediates = new List<Intermediate>(); | ||
| 168 | |||
| 169 | foreach (var sourceFile in sourceFiles) | ||
| 170 | { | ||
| 131 | var preprocessor = new Preprocessor(this.ServiceProvider); | 171 | var preprocessor = new Preprocessor(this.ServiceProvider); |
| 132 | preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; | 172 | preprocessor.IncludeSearchPaths = this.IncludeSearchPaths; |
| 133 | preprocessor.Platform = Platform.X86; // TODO: set this correctly | 173 | preprocessor.Platform = Platform.X86; // TODO: set this correctly |
| @@ -159,12 +199,6 @@ namespace WixToolset.Core.CommandLine | |||
| 159 | 199 | ||
| 160 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations) | 200 | private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations) |
| 161 | { | 201 | { |
| 162 | // If there was an error loading localization files, then bail. | ||
| 163 | if (this.Messaging.EncounteredError) | ||
| 164 | { | ||
| 165 | return null; | ||
| 166 | } | ||
| 167 | |||
| 168 | var librarian = new Librarian(this.ServiceProvider); | 202 | var librarian = new Librarian(this.ServiceProvider); |
| 169 | librarian.BindFiles = this.BindFiles; | 203 | librarian.BindFiles = this.BindFiles; |
| 170 | librarian.BindPaths = this.BindPaths; | 204 | librarian.BindPaths = this.BindPaths; |
| @@ -173,10 +207,8 @@ namespace WixToolset.Core.CommandLine | |||
| 173 | return librarian.Execute(); | 207 | return librarian.Execute(); |
| 174 | } | 208 | } |
| 175 | 209 | ||
| 176 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates) | 210 | private Intermediate LinkPhase(IEnumerable<Intermediate> intermediates, ITupleDefinitionCreator creator) |
| 177 | { | 211 | { |
| 178 | var creator = this.ServiceProvider.GetService<ITupleDefinitionCreator>(); | ||
| 179 | |||
| 180 | var libraries = this.LoadLibraries(creator); | 212 | var libraries = this.LoadLibraries(creator); |
| 181 | 213 | ||
| 182 | if (this.Messaging.EncounteredError) | 214 | if (this.Messaging.EncounteredError) |
| @@ -194,12 +226,6 @@ namespace WixToolset.Core.CommandLine | |||
| 194 | 226 | ||
| 195 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations) | 227 | private void BindPhase(Intermediate output, IEnumerable<Localization> localizations) |
| 196 | { | 228 | { |
| 197 | // If there was an error loading localization files, then bail. | ||
| 198 | if (this.Messaging.EncounteredError) | ||
| 199 | { | ||
| 200 | return; | ||
| 201 | } | ||
| 202 | |||
| 203 | ResolveResult resolveResult; | 229 | ResolveResult resolveResult; |
| 204 | { | 230 | { |
| 205 | var resolver = new Resolver(this.ServiceProvider); | 231 | var resolver = new Resolver(this.ServiceProvider); |
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs new file mode 100644 index 00000000..498b1492 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolsetTest.CoreIntegration | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using System.Linq; | ||
| 7 | using WixBuildTools.TestSupport; | ||
| 8 | using WixToolset.Core.TestPackage; | ||
| 9 | using WixToolset.Data; | ||
| 10 | using WixToolset.Data.Tuples; | ||
| 11 | using Xunit; | ||
| 12 | |||
| 13 | public class WixiplFixture | ||
| 14 | { | ||
| 15 | [Fact] | ||
| 16 | public void CanBuildSingleFile() | ||
| 17 | { | ||
| 18 | var folder = TestData.Get(@"TestData\SingleFile"); | ||
| 19 | |||
| 20 | using (var fs = new DisposableFileSystem()) | ||
| 21 | { | ||
| 22 | var baseFolder = fs.GetFolder(); | ||
| 23 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 24 | |||
| 25 | var result = WixRunner.Execute(new[] | ||
| 26 | { | ||
| 27 | "build", | ||
| 28 | Path.Combine(folder, "Package.wxs"), | ||
| 29 | Path.Combine(folder, "PackageComponents.wxs"), | ||
| 30 | "-intermediateFolder", intermediateFolder, | ||
| 31 | "-o", Path.Combine(intermediateFolder, @"test.wixipl") | ||
| 32 | }, out var messagesCompile); | ||
| 33 | Assert.Equal(0, result); | ||
| 34 | |||
| 35 | result = WixRunner.Execute(new[] | ||
| 36 | { | ||
| 37 | "build", | ||
| 38 | Path.Combine(intermediateFolder, @"test.wixipl"), | ||
| 39 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
| 40 | "-bindpath", Path.Combine(folder, "data"), | ||
| 41 | "-intermediateFolder", intermediateFolder, | ||
| 42 | "-o", Path.Combine(baseFolder, @"bin\test.msi") | ||
| 43 | }, out var messagesBind); | ||
| 44 | Assert.Equal(0, result); | ||
| 45 | |||
| 46 | var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wir")); | ||
| 47 | var section = intermediate.Sections.Single(); | ||
| 48 | |||
| 49 | var wixFile = section.Tuples.OfType<WixFileTuple>().Single(); | ||
| 50 | Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); | ||
| 51 | Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | [Fact] | ||
| 56 | public void CannotBuildWithSourceFileAndWixipl() | ||
| 57 | { | ||
| 58 | var folder = TestData.Get(@"TestData\SingleFile"); | ||
| 59 | |||
| 60 | using (var fs = new DisposableFileSystem()) | ||
| 61 | { | ||
| 62 | var baseFolder = fs.GetFolder(); | ||
| 63 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 64 | |||
| 65 | var result = WixRunner.Execute(new[] | ||
| 66 | { | ||
| 67 | "build", | ||
| 68 | Path.Combine(folder, "Package.wxs"), | ||
| 69 | Path.Combine(folder, "PackageComponents.wxs"), | ||
| 70 | "-intermediateFolder", intermediateFolder, | ||
| 71 | "-o", Path.Combine(intermediateFolder, @"test.wixipl") | ||
| 72 | }, out var messagesCompile); | ||
| 73 | Assert.Equal(0, result); | ||
| 74 | |||
| 75 | result = WixRunner.Execute(new[] | ||
| 76 | { | ||
| 77 | "build", | ||
| 78 | Path.Combine(folder, "Package.wxs"), | ||
| 79 | Path.Combine(intermediateFolder, @"test.wixipl"), | ||
| 80 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
| 81 | "-bindpath", Path.Combine(folder, "data"), | ||
| 82 | "-intermediateFolder", intermediateFolder, | ||
| 83 | "-o", Path.Combine(baseFolder, @"bin\test.msi") | ||
| 84 | }, out var messagesBind); | ||
| 85 | Assert.Equal((int)ErrorMessages.Ids.WixiplSourceFileIsExclusive, result); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } | ||
| 89 | } | ||
