Improve missing entry section error message.
Fixes https://github.com/wixtoolset/issues/issues/5886
Bob Arnson committed
Mar 7, 2021 at 17:37 UTC
24082aafc87c9cc3ed22749e6b21d80e0d3e6ced
2 files changed
+98
-1
src/WixToolset.Core/Linker.cs
+8
-1
@@ -106,7 +106,14 @@ namespace WixToolset.Core
106
// Must have found the entry section by now.
107
if (null == find.EntrySection)
108
{
109
- throw new WixException(ErrorMessages.MissingEntrySection(this.Context.ExpectedOutputType.ToString()));
109
+ if (this.Context.ExpectedOutputType == OutputType.IntermediatePostLink || this.Context.ExpectedOutputType == OutputType.Unknown)
110
+ {
111
+ throw new WixException(ErrorMessages.MissingEntrySection());
112
+ }
113
+ else
114
+ {
115
+ throw new WixException(ErrorMessages.MissingEntrySection(this.Context.ExpectedOutputType.ToString()));
116
+ }
117
}
118
119
// Add the missing standard action and directory symbols.
src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs
+90
@@ -79,5 +79,95 @@ namespace WixToolsetTest.CoreIntegration
79
//Assert.Equal(@"test.txt", wixFile[WixFileSymbolFields.Source].PreviousValue.AsPath().Path);
80
}
81
}
82
+
83
+ [Fact]
84
+ public void MissingEntrySectionDetectedProduct()
85
+ {
86
+ var folder = TestData.Get(@"TestData\OverridableActions");
87
+
88
+ using (var fs = new DisposableFileSystem())
89
+ {
90
+ var baseFolder = fs.GetFolder();
91
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
92
+
93
+ try
94
+ {
95
+ WixRunner.Execute(new[]
96
+ {
97
+ "build",
98
+ Path.Combine(folder, "PackageComponents.wxs"),
99
+ "-intermediateFolder", intermediateFolder,
100
+ "-o", Path.Combine(baseFolder, @"bin\test.msi")
101
+ });
102
+ }
103
+ catch (WixException we)
104
+ {
105
+ Assert.Equal("Could not find entry section in provided list of intermediates. Expected section of type 'Product'.", we.Message);
106
+ return;
107
+ }
108
+
109
+ Assert.True(false, "Expected WixException for missing entry section but expectations were not met.");
110
+ }
111
+ }
112
+
113
+ [Fact]
114
+ public void MissingEntrySectionDetectedWixipl()
115
+ {
116
+ var folder = TestData.Get(@"TestData\OverridableActions");
117
+
118
+ using (var fs = new DisposableFileSystem())
119
+ {
120
+ var baseFolder = fs.GetFolder();
121
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
122
+
123
+ try
124
+ {
125
+ WixRunner.Execute(new[]
126
+ {
127
+ "build",
128
+ Path.Combine(folder, "PackageComponents.wxs"),
129
+ "-intermediateFolder", intermediateFolder,
130
+ "-o", Path.Combine(baseFolder, @"bin\test.wixipl")
131
+ });
132
+ }
133
+ catch (WixException we)
134
+ {
135
+ Assert.Equal("Could not find entry section in provided list of intermediates. Supported entry section types are: Product, Bundle, Patch, PatchCreation, Module.", we.Message);
136
+ return;
137
+ }
138
+
139
+ Assert.True(false, "Expected WixException for missing entry section but expectations were not met.");
140
+ }
141
+ }
142
+
143
+ [Fact]
144
+ public void MissingEntrySectionDetectedUnknown()
145
+ {
146
+ var folder = TestData.Get(@"TestData\OverridableActions");
147
+
148
+ using (var fs = new DisposableFileSystem())
149
+ {
150
+ var baseFolder = fs.GetFolder();
151
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
152
+
153
+ try
154
+ {
155
+ WixRunner.Execute(new[]
156
+ {
157
+ "build",
158
+ Path.Combine(folder, "PackageComponents.wxs"),
159
+ "-intermediateFolder", intermediateFolder,
160
+ "-o", Path.Combine(baseFolder, @"bin\test.bob")
161
+ });
162
+ }
163
+ catch (WixException we)
164
+ {
165
+ Assert.Equal("Could not find entry section in provided list of intermediates. Supported entry section types are: Product, Bundle, Patch, PatchCreation, Module.", we.Message);
166
+ return;
167
+ }
168
+
169
+ Assert.True(false, "Expected WixException for missing entry section but expectations were not met.");
170
+ }
171
+ }
172
}
173
}