aboutsummaryrefslogtreecommitdiff
path: root/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs')
-rw-r--r--src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs b/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs
index 8211bf83..e63bf65c 100644
--- a/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs
+++ b/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs
@@ -71,11 +71,11 @@ namespace WixToolset.Core.Burn.Bundles
71 FileSystem.CopyFile(stubFile, bundleTempPath, allowHardlink: false); 71 FileSystem.CopyFile(stubFile, bundleTempPath, allowHardlink: false);
72 File.SetAttributes(bundleTempPath, FileAttributes.Normal); 72 File.SetAttributes(bundleTempPath, FileAttributes.Normal);
73 73
74 var windowsAssemblyVersion = GetWindowsAssemblyVersion(this.BundleSymbol); 74 var fourPartVersion = this.GetFourPartVersion(this.BundleSymbol);
75 75
76 var applicationManifestData = GenerateApplicationManifest(this.BundleSymbol, this.BootstrapperApplicationDllSymbol, this.OutputPath, windowsAssemblyVersion); 76 var applicationManifestData = GenerateApplicationManifest(this.BundleSymbol, this.BootstrapperApplicationDllSymbol, this.OutputPath, fourPartVersion);
77 77
78 UpdateBurnResources(bundleTempPath, this.OutputPath, this.BundleSymbol, windowsAssemblyVersion, applicationManifestData); 78 this.UpdateBurnResources(bundleTempPath, this.OutputPath, this.BundleSymbol, fourPartVersion, applicationManifestData);
79 79
80 // Update the .wixburn section to point to at the UX and attached container(s) then attach the containers 80 // Update the .wixburn section to point to at the UX and attached container(s) then attach the containers
81 // if they should be attached. 81 // if they should be attached.
@@ -242,24 +242,37 @@ namespace WixToolset.Core.Burn.Bundles
242 } 242 }
243 } 243 }
244 244
245 private static Version GetWindowsAssemblyVersion(WixBundleSymbol bundleSymbol) 245 private Version GetFourPartVersion(WixBundleSymbol bundleSymbol)
246 { 246 {
247 // Ensure the bundle info provides a full four part version. 247 // Ensure the bundle info provides a full four-part version.
248 var fourPartVersion = new Version(bundleSymbol.Version); 248
249 var major = (fourPartVersion.Major < 0) ? 0 : fourPartVersion.Major; 249 if (!WixVersion.TryParse(bundleSymbol.Version, out var wixVersion))
250 var minor = (fourPartVersion.Minor < 0) ? 0 : fourPartVersion.Minor; 250 {
251 var build = (fourPartVersion.Build < 0) ? 0 : fourPartVersion.Build; 251 // Display an error message indicating that we will require a four-part version number
252 var revision = (fourPartVersion.Revision < 0) ? 0 : fourPartVersion.Revision; 252 // not just a WixVersion.
253 this.Messaging.Write(ErrorMessages.IllegalVersionValue(bundleSymbol.SourceLineNumbers, "Bundle", "Version", bundleSymbol.Version));
254 return new Version(0, 0);
255 }
256
257 var major = wixVersion.Major ?? 0;
258 var minor = wixVersion.Minor ?? 0;
259 var build = wixVersion.Patch ?? 0;
260 var revision = wixVersion.Revision ?? 0;
253 261
254 if (UInt16.MaxValue < major || UInt16.MaxValue < minor || UInt16.MaxValue < build || UInt16.MaxValue < revision) 262 if (UInt16.MaxValue < major || UInt16.MaxValue < minor || UInt16.MaxValue < build || UInt16.MaxValue < revision)
255 { 263 {
256 throw new WixException(ErrorMessages.InvalidModuleOrBundleVersion(bundleSymbol.SourceLineNumbers, "Bundle", bundleSymbol.Version)); 264 major = Math.Max(major, UInt16.MaxValue);
265 minor = Math.Max(minor, UInt16.MaxValue);
266 build = Math.Max(build, UInt16.MaxValue);
267 revision = Math.Max(revision, UInt16.MaxValue);
268
269 this.Messaging.Write(BurnBackendWarnings.CannotParseBundleVersionAsFourPartVersion(bundleSymbol.SourceLineNumbers, bundleSymbol.Version));
257 } 270 }
258 271
259 return new Version(major, minor, build, revision); 272 return new Version((int)major, (int)minor, (int)build, (int)revision);
260 } 273 }
261 274
262 private void UpdateBurnResources(string bundleTempPath, string outputPath, WixBundleSymbol bundleInfo, Version windowsAssemblyVersion, byte[] applicationManifestData) 275 private void UpdateBurnResources(string bundleTempPath, string outputPath, WixBundleSymbol bundleInfo, Version fourPartVersion, byte[] applicationManifestData)
263 { 276 {
264 const int burnLocale = 1033; 277 const int burnLocale = 1033;
265 var resources = new ResourceCollection(); 278 var resources = new ResourceCollection();
@@ -268,8 +281,8 @@ namespace WixToolset.Core.Burn.Bundles
268 version.Load(bundleTempPath); 281 version.Load(bundleTempPath);
269 resources.Add(version); 282 resources.Add(version);
270 283
271 version.FileVersion = windowsAssemblyVersion; 284 version.FileVersion = fourPartVersion;
272 version.ProductVersion = windowsAssemblyVersion; 285 version.ProductVersion = fourPartVersion;
273 286
274 var strings = version[burnLocale] ?? version.Add(burnLocale); 287 var strings = version[burnLocale] ?? version.Add(burnLocale);
275 strings["LegalCopyright"] = bundleInfo.Copyright; 288 strings["LegalCopyright"] = bundleInfo.Copyright;