From 3051bf2fc300df125115c9538a0bfc8256bfde6a Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 22 May 2019 16:28:02 -0700 Subject: Integrate short and source name changes to Directory and Shortcut tuples --- .../Bind/CalculateComponentGuids.cs | 7 ++- .../Bind/CreateOutputFromIRCommand.cs | 38 +++++++++++++-- src/WixToolset.Core/Compiler.cs | 8 ++-- src/WixToolset.Core/Compiler_2.cs | 55 +--------------------- .../ExtensibilityServices/ParseHelper.cs | 36 ++++---------- .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 2 +- .../TestData/SingleFileCompressed/Package.wxs | 2 +- 7 files changed, 55 insertions(+), 93 deletions(-) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs index f66ff375..835d9b8d 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs @@ -76,18 +76,17 @@ namespace WixToolset.Core.WindowsInstaller.Bind targetPathsByDirectoryId = new Dictionary(directories.Count); // Get the target paths for all directories. - foreach (var row in directories) + foreach (var directory in directories) { // If the directory Id already exists, we will skip it here since // checking for duplicate primary keys is done later when importing tables // into database - if (targetPathsByDirectoryId.ContainsKey(row.Id.Id)) + if (targetPathsByDirectoryId.ContainsKey(directory.Id.Id)) { continue; } - var targetName = Common.GetName(row.DefaultDir, false, true); - targetPathsByDirectoryId.Add(row.Id.Id, new ResolvedDirectory(row.ParentDirectoryRef, targetName)); + targetPathsByDirectoryId.Add(directory.Id.Id, new ResolvedDirectory(directory.ParentDirectoryRef, directory.Name)); } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs index 65958d0a..57861502 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs @@ -146,7 +146,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; case TupleDefinitionType.Shortcut: - this.AddTupleDefaultly(tuple, output, true); + this.AddShortcutTuple((ShortcutTuple)tuple, output); break; case TupleDefinitionType.TextStyle: @@ -338,11 +338,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind private void AddDirectoryTuple(DirectoryTuple tuple, Output output) { + var shortName = GetMsiFilenameValue(tuple.SourceShortName, tuple.SourceName); + var targetName = GetMsiFilenameValue(tuple.ShortName, tuple.Name); + + if (String.IsNullOrEmpty(targetName)) + { + targetName = "."; + } + + var defaultDir = String.IsNullOrEmpty(shortName)? targetName : shortName + ":" + targetName; + var table = output.EnsureTable(this.TableDefinitions["Directory"]); var row = table.CreateRow(tuple.SourceLineNumbers); row[0] = tuple.Id.Id; row[1] = tuple.ParentDirectoryRef; - row[2] = tuple.DefaultDir; + row[2] = defaultDir; } private void AddEnvironmentTuple(EnvironmentTuple tuple, Output output) @@ -447,7 +457,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind var table = output.EnsureTable(this.TableDefinitions["Media"]); var row = (MediaRow)table.CreateRow(tuple.SourceLineNumbers); row.DiskId = tuple.DiskId; - row.LastSequence = tuple.LastSequence; + row.LastSequence = tuple.LastSequence ?? 0; row.DiskPrompt = tuple.DiskPrompt; row.Cabinet = tuple.Cabinet; row.VolumeLabel = tuple.VolumeLabel; @@ -695,6 +705,28 @@ namespace WixToolset.Core.WindowsInstaller.Bind row[12] = tuple.Description; } + private void AddShortcutTuple(ShortcutTuple tuple, Output output) + { + var table = output.EnsureTable(this.TableDefinitions["Shortcut"]); + var row = table.CreateRow(tuple.SourceLineNumbers); + row[0] = tuple.Id.Id; + row[1] = tuple.DirectoryRef; + row[2] = GetMsiFilenameValue(tuple.ShortName, tuple.Name); + row[3] = tuple.ComponentRef; + row[4] = tuple.Target; + row[5] = tuple.Arguments; + row[6] = tuple.Description; + row[7] = tuple.Hotkey; + row[8] = tuple.IconRef; + row[9] = tuple.IconIndex; + row[10] = (int)tuple.Show; + row[11] = tuple.WorkingDirectory; + row[12] = tuple.DisplayResourceDll; + row[13] = tuple.DisplayResourceId; + row[14] = tuple.DescriptionResourceDll; + row[15] = tuple.DescriptionResourceId; + } + private void AddTextStyleTuple(TextStyleTuple tuple, Output output) { var styleBits = tuple.Bold ? WindowsInstallerConstants.MsidbTextStyleStyleBitsBold : 0; diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index ea018d54..d543c6b8 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -4028,7 +4028,6 @@ namespace WixToolset.Core string shortName = null; string sourceName = null; string shortSourceName = null; - string defaultDir = null; string symbols = null; foreach (var attrib in node.Attributes()) @@ -4208,7 +4207,7 @@ namespace WixToolset.Core } // Calculate the DefaultDir for the directory row. - defaultDir = String.IsNullOrEmpty(shortName) ? name : String.Concat(shortName, "|", name); + var defaultDir = String.IsNullOrEmpty(shortName) ? name : String.Concat(shortName, "|", name); if (!String.IsNullOrEmpty(sourceName)) { defaultDir = String.Concat(defaultDir, ":", String.IsNullOrEmpty(shortSourceName) ? sourceName : String.Concat(shortSourceName, "|", sourceName)); @@ -4260,7 +4259,10 @@ namespace WixToolset.Core var tuple = new DirectoryTuple(sourceLineNumbers, id) { ParentDirectoryRef = parentId, - DefaultDir = defaultDir, + Name = name, + ShortName = shortName, + SourceName = sourceName, + SourceShortName = shortSourceName, ComponentGuidGenerationSeed = componentGuidGenerationSeed }; diff --git a/src/WixToolset.Core/Compiler_2.cs b/src/WixToolset.Core/Compiler_2.cs index beebd4f8..9e965465 100644 --- a/src/WixToolset.Core/Compiler_2.cs +++ b/src/WixToolset.Core/Compiler_2.cs @@ -4401,7 +4401,8 @@ namespace WixToolset.Core var tuple = new ShortcutTuple(sourceLineNumbers, id) { DirectoryRef = directory, - Name = this.GetMsiFilenameValue(shortName, name), + Name = name, + ShortName = shortName, ComponentRef = componentId, Target = target, Arguments = arguments, @@ -4418,58 +4419,6 @@ namespace WixToolset.Core }; this.Core.AddTuple(tuple); - - //var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Shortcut, id); - //row.Set(1, directory); - //row.Set(2, this.GetMsiFilenameValue(shortName, name)); - //row.Set(3, componentId); - //if (advertise) - //{ - // if (YesNoType.Yes != parentKeyPath && "Component" != parentElementLocalName) - // { - // this.Core.Write(WarningMessages.UnclearShortcut(sourceLineNumbers, id.Id, componentId, defaultTarget)); - // } - // row.Set(4, Guid.Empty.ToString("B")); - //} - //else if (null != target) - //{ - // row.Set(4, target); - //} - //else if ("Component" == parentElementLocalName || "CreateFolder" == parentElementLocalName) - //{ - // row.Set(4, String.Format(CultureInfo.InvariantCulture, "[{0}]", defaultTarget)); - //} - //else if ("File" == parentElementLocalName) - //{ - // row.Set(4, String.Format(CultureInfo.InvariantCulture, "[#{0}]", defaultTarget)); - //} - //row.Set(5, arguments); - //row.Set(6, description); - //if (CompilerConstants.IntegerNotSet != hotkey) - //{ - // row.Set(7, hotkey); - //} - //row.Set(8, icon); - //if (CompilerConstants.IntegerNotSet != iconIndex) - //{ - // row.Set(9, iconIndex); - //} - - //if (show.HasValue) - //{ - // row.Set(10, show.Value); - //} - //row.Set(11, workingDirectory); - //row.Set(12, displayResourceDll); - //if (CompilerConstants.IntegerNotSet != displayResourceId) - //{ - // row.Set(13, displayResourceId); - //} - //row.Set(14, descriptionResourceDll); - //if (CompilerConstants.IntegerNotSet != descriptionResourceId) - //{ - // row.Set(15, descriptionResourceId); - //} } } diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index 0e80100b..3318b914 100644 --- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs @@ -77,37 +77,14 @@ namespace WixToolset.Core.ExtensibilityServices public Identifier CreateDirectoryTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, ISet sectionInlinedDirectoryIds, string shortName = null, string sourceName = null, string shortSourceName = null) { - string defaultDir; - - if (name.Equals("SourceDir") || this.IsValidShortFilename(name, false)) - { - defaultDir = name; - } - else + if (String.IsNullOrEmpty(shortName) && !name.Equals("SourceDir") && !this.IsValidShortFilename(name)) { - if (String.IsNullOrEmpty(shortName)) - { - shortName = this.CreateShortName(name, false, false, "Directory", parentId); - } - - defaultDir = String.Concat(shortName, "|", name); + shortName = this.CreateShortName(name, false, false, "Directory", parentId); } - if (!String.IsNullOrEmpty(sourceName)) + if (String.IsNullOrEmpty(shortSourceName) && !String.IsNullOrEmpty(sourceName) && !this.IsValidShortFilename(sourceName)) { - if (this.IsValidShortFilename(sourceName, false)) - { - defaultDir = String.Concat(defaultDir, ":", sourceName); - } - else - { - if (String.IsNullOrEmpty(shortSourceName)) - { - shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId); - } - - defaultDir = String.Concat(defaultDir, ":", shortSourceName, "|", sourceName); - } + shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId); } // For anonymous directories, create the identifier. If this identifier already exists in the @@ -126,7 +103,10 @@ namespace WixToolset.Core.ExtensibilityServices var tuple = new DirectoryTuple(sourceLineNumbers, id) { ParentDirectoryRef = parentId, - DefaultDir = defaultDir, + Name = name, + ShortName = shortName, + SourceName = sourceName, + SourceShortName = shortSourceName }; section.Tuples.Add(tuple); diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index 8228ebfa..a329c16a 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs @@ -137,7 +137,7 @@ namespace WixToolsetTest.CoreIntegration result.AssertSuccess(); Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi"))); - Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\lowcab1.cab"))); + Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\low1.cab"))); Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); } } diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFileCompressed/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFileCompressed/Package.wxs index 8bb1f6af..c21a669c 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFileCompressed/Package.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFileCompressed/Package.wxs @@ -10,7 +10,7 @@ - + -- cgit v1.2.3-55-g6feb