aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2019-05-22 16:28:02 -0700
committerRob Mensching <rob@firegiant.com>2019-05-23 16:02:37 -0700
commit3051bf2fc300df125115c9538a0bfc8256bfde6a (patch)
tree65aa2e091a6a5fa983314ab9cb55a72ba16faf02
parent3859a8cd7d6001f7b49c22065e33242ddb486fbb (diff)
downloadwix-3051bf2fc300df125115c9538a0bfc8256bfde6a.tar.gz
wix-3051bf2fc300df125115c9538a0bfc8256bfde6a.tar.bz2
wix-3051bf2fc300df125115c9538a0bfc8256bfde6a.zip
Integrate short and source name changes to Directory and Shortcut tuples
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs7
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs38
-rw-r--r--src/WixToolset.Core/Compiler.cs8
-rw-r--r--src/WixToolset.Core/Compiler_2.cs55
-rw-r--r--src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs36
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs2
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/SingleFileCompressed/Package.wxs2
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
76 targetPathsByDirectoryId = new Dictionary<string, ResolvedDirectory>(directories.Count); 76 targetPathsByDirectoryId = new Dictionary<string, ResolvedDirectory>(directories.Count);
77 77
78 // Get the target paths for all directories. 78 // Get the target paths for all directories.
79 foreach (var row in directories) 79 foreach (var directory in directories)
80 { 80 {
81 // If the directory Id already exists, we will skip it here since 81 // If the directory Id already exists, we will skip it here since
82 // checking for duplicate primary keys is done later when importing tables 82 // checking for duplicate primary keys is done later when importing tables
83 // into database 83 // into database
84 if (targetPathsByDirectoryId.ContainsKey(row.Id.Id)) 84 if (targetPathsByDirectoryId.ContainsKey(directory.Id.Id))
85 { 85 {
86 continue; 86 continue;
87 } 87 }
88 88
89 var targetName = Common.GetName(row.DefaultDir, false, true); 89 targetPathsByDirectoryId.Add(directory.Id.Id, new ResolvedDirectory(directory.ParentDirectoryRef, directory.Name));
90 targetPathsByDirectoryId.Add(row.Id.Id, new ResolvedDirectory(row.ParentDirectoryRef, targetName));
91 } 90 }
92 } 91 }
93 92
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
146 break; 146 break;
147 147
148 case TupleDefinitionType.Shortcut: 148 case TupleDefinitionType.Shortcut:
149 this.AddTupleDefaultly(tuple, output, true); 149 this.AddShortcutTuple((ShortcutTuple)tuple, output);
150 break; 150 break;
151 151
152 case TupleDefinitionType.TextStyle: 152 case TupleDefinitionType.TextStyle:
@@ -338,11 +338,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind
338 338
339 private void AddDirectoryTuple(DirectoryTuple tuple, Output output) 339 private void AddDirectoryTuple(DirectoryTuple tuple, Output output)
340 { 340 {
341 var shortName = GetMsiFilenameValue(tuple.SourceShortName, tuple.SourceName);
342 var targetName = GetMsiFilenameValue(tuple.ShortName, tuple.Name);
343
344 if (String.IsNullOrEmpty(targetName))
345 {
346 targetName = ".";
347 }
348
349 var defaultDir = String.IsNullOrEmpty(shortName)? targetName : shortName + ":" + targetName;
350
341 var table = output.EnsureTable(this.TableDefinitions["Directory"]); 351 var table = output.EnsureTable(this.TableDefinitions["Directory"]);
342 var row = table.CreateRow(tuple.SourceLineNumbers); 352 var row = table.CreateRow(tuple.SourceLineNumbers);
343 row[0] = tuple.Id.Id; 353 row[0] = tuple.Id.Id;
344 row[1] = tuple.ParentDirectoryRef; 354 row[1] = tuple.ParentDirectoryRef;
345 row[2] = tuple.DefaultDir; 355 row[2] = defaultDir;
346 } 356 }
347 357
348 private void AddEnvironmentTuple(EnvironmentTuple tuple, Output output) 358 private void AddEnvironmentTuple(EnvironmentTuple tuple, Output output)
@@ -447,7 +457,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
447 var table = output.EnsureTable(this.TableDefinitions["Media"]); 457 var table = output.EnsureTable(this.TableDefinitions["Media"]);
448 var row = (MediaRow)table.CreateRow(tuple.SourceLineNumbers); 458 var row = (MediaRow)table.CreateRow(tuple.SourceLineNumbers);
449 row.DiskId = tuple.DiskId; 459 row.DiskId = tuple.DiskId;
450 row.LastSequence = tuple.LastSequence; 460 row.LastSequence = tuple.LastSequence ?? 0;
451 row.DiskPrompt = tuple.DiskPrompt; 461 row.DiskPrompt = tuple.DiskPrompt;
452 row.Cabinet = tuple.Cabinet; 462 row.Cabinet = tuple.Cabinet;
453 row.VolumeLabel = tuple.VolumeLabel; 463 row.VolumeLabel = tuple.VolumeLabel;
@@ -695,6 +705,28 @@ namespace WixToolset.Core.WindowsInstaller.Bind
695 row[12] = tuple.Description; 705 row[12] = tuple.Description;
696 } 706 }
697 707
708 private void AddShortcutTuple(ShortcutTuple tuple, Output output)
709 {
710 var table = output.EnsureTable(this.TableDefinitions["Shortcut"]);
711 var row = table.CreateRow(tuple.SourceLineNumbers);
712 row[0] = tuple.Id.Id;
713 row[1] = tuple.DirectoryRef;
714 row[2] = GetMsiFilenameValue(tuple.ShortName, tuple.Name);
715 row[3] = tuple.ComponentRef;
716 row[4] = tuple.Target;
717 row[5] = tuple.Arguments;
718 row[6] = tuple.Description;
719 row[7] = tuple.Hotkey;
720 row[8] = tuple.IconRef;
721 row[9] = tuple.IconIndex;
722 row[10] = (int)tuple.Show;
723 row[11] = tuple.WorkingDirectory;
724 row[12] = tuple.DisplayResourceDll;
725 row[13] = tuple.DisplayResourceId;
726 row[14] = tuple.DescriptionResourceDll;
727 row[15] = tuple.DescriptionResourceId;
728 }
729
698 private void AddTextStyleTuple(TextStyleTuple tuple, Output output) 730 private void AddTextStyleTuple(TextStyleTuple tuple, Output output)
699 { 731 {
700 var styleBits = tuple.Bold ? WindowsInstallerConstants.MsidbTextStyleStyleBitsBold : 0; 732 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
4028 string shortName = null; 4028 string shortName = null;
4029 string sourceName = null; 4029 string sourceName = null;
4030 string shortSourceName = null; 4030 string shortSourceName = null;
4031 string defaultDir = null;
4032 string symbols = null; 4031 string symbols = null;
4033 4032
4034 foreach (var attrib in node.Attributes()) 4033 foreach (var attrib in node.Attributes())
@@ -4208,7 +4207,7 @@ namespace WixToolset.Core
4208 } 4207 }
4209 4208
4210 // Calculate the DefaultDir for the directory row. 4209 // Calculate the DefaultDir for the directory row.
4211 defaultDir = String.IsNullOrEmpty(shortName) ? name : String.Concat(shortName, "|", name); 4210 var defaultDir = String.IsNullOrEmpty(shortName) ? name : String.Concat(shortName, "|", name);
4212 if (!String.IsNullOrEmpty(sourceName)) 4211 if (!String.IsNullOrEmpty(sourceName))
4213 { 4212 {
4214 defaultDir = String.Concat(defaultDir, ":", String.IsNullOrEmpty(shortSourceName) ? sourceName : String.Concat(shortSourceName, "|", sourceName)); 4213 defaultDir = String.Concat(defaultDir, ":", String.IsNullOrEmpty(shortSourceName) ? sourceName : String.Concat(shortSourceName, "|", sourceName));
@@ -4260,7 +4259,10 @@ namespace WixToolset.Core
4260 var tuple = new DirectoryTuple(sourceLineNumbers, id) 4259 var tuple = new DirectoryTuple(sourceLineNumbers, id)
4261 { 4260 {
4262 ParentDirectoryRef = parentId, 4261 ParentDirectoryRef = parentId,
4263 DefaultDir = defaultDir, 4262 Name = name,
4263 ShortName = shortName,
4264 SourceName = sourceName,
4265 SourceShortName = shortSourceName,
4264 ComponentGuidGenerationSeed = componentGuidGenerationSeed 4266 ComponentGuidGenerationSeed = componentGuidGenerationSeed
4265 }; 4267 };
4266 4268
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
4401 var tuple = new ShortcutTuple(sourceLineNumbers, id) 4401 var tuple = new ShortcutTuple(sourceLineNumbers, id)
4402 { 4402 {
4403 DirectoryRef = directory, 4403 DirectoryRef = directory,
4404 Name = this.GetMsiFilenameValue(shortName, name), 4404 Name = name,
4405 ShortName = shortName,
4405 ComponentRef = componentId, 4406 ComponentRef = componentId,
4406 Target = target, 4407 Target = target,
4407 Arguments = arguments, 4408 Arguments = arguments,
@@ -4418,58 +4419,6 @@ namespace WixToolset.Core
4418 }; 4419 };
4419 4420
4420 this.Core.AddTuple(tuple); 4421 this.Core.AddTuple(tuple);
4421
4422 //var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Shortcut, id);
4423 //row.Set(1, directory);
4424 //row.Set(2, this.GetMsiFilenameValue(shortName, name));
4425 //row.Set(3, componentId);
4426 //if (advertise)
4427 //{
4428 // if (YesNoType.Yes != parentKeyPath && "Component" != parentElementLocalName)
4429 // {
4430 // this.Core.Write(WarningMessages.UnclearShortcut(sourceLineNumbers, id.Id, componentId, defaultTarget));
4431 // }
4432 // row.Set(4, Guid.Empty.ToString("B"));
4433 //}
4434 //else if (null != target)
4435 //{
4436 // row.Set(4, target);
4437 //}
4438 //else if ("Component" == parentElementLocalName || "CreateFolder" == parentElementLocalName)
4439 //{
4440 // row.Set(4, String.Format(CultureInfo.InvariantCulture, "[{0}]", defaultTarget));
4441 //}
4442 //else if ("File" == parentElementLocalName)
4443 //{
4444 // row.Set(4, String.Format(CultureInfo.InvariantCulture, "[#{0}]", defaultTarget));
4445 //}
4446 //row.Set(5, arguments);
4447 //row.Set(6, description);
4448 //if (CompilerConstants.IntegerNotSet != hotkey)
4449 //{
4450 // row.Set(7, hotkey);
4451 //}
4452 //row.Set(8, icon);
4453 //if (CompilerConstants.IntegerNotSet != iconIndex)
4454 //{
4455 // row.Set(9, iconIndex);
4456 //}
4457
4458 //if (show.HasValue)
4459 //{
4460 // row.Set(10, show.Value);
4461 //}
4462 //row.Set(11, workingDirectory);
4463 //row.Set(12, displayResourceDll);
4464 //if (CompilerConstants.IntegerNotSet != displayResourceId)
4465 //{
4466 // row.Set(13, displayResourceId);
4467 //}
4468 //row.Set(14, descriptionResourceDll);
4469 //if (CompilerConstants.IntegerNotSet != descriptionResourceId)
4470 //{
4471 // row.Set(15, descriptionResourceId);
4472 //}
4473 } 4422 }
4474 } 4423 }
4475 4424
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
77 77
78 public Identifier CreateDirectoryTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, ISet<string> sectionInlinedDirectoryIds, string shortName = null, string sourceName = null, string shortSourceName = null) 78 public Identifier CreateDirectoryTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, ISet<string> sectionInlinedDirectoryIds, string shortName = null, string sourceName = null, string shortSourceName = null)
79 { 79 {
80 string defaultDir; 80 if (String.IsNullOrEmpty(shortName) && !name.Equals("SourceDir") && !this.IsValidShortFilename(name))
81
82 if (name.Equals("SourceDir") || this.IsValidShortFilename(name, false))
83 {
84 defaultDir = name;
85 }
86 else
87 { 81 {
88 if (String.IsNullOrEmpty(shortName)) 82 shortName = this.CreateShortName(name, false, false, "Directory", parentId);
89 {
90 shortName = this.CreateShortName(name, false, false, "Directory", parentId);
91 }
92
93 defaultDir = String.Concat(shortName, "|", name);
94 } 83 }
95 84
96 if (!String.IsNullOrEmpty(sourceName)) 85 if (String.IsNullOrEmpty(shortSourceName) && !String.IsNullOrEmpty(sourceName) && !this.IsValidShortFilename(sourceName))
97 { 86 {
98 if (this.IsValidShortFilename(sourceName, false)) 87 shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId);
99 {
100 defaultDir = String.Concat(defaultDir, ":", sourceName);
101 }
102 else
103 {
104 if (String.IsNullOrEmpty(shortSourceName))
105 {
106 shortSourceName = this.CreateShortName(sourceName, false, false, "Directory", parentId);
107 }
108
109 defaultDir = String.Concat(defaultDir, ":", shortSourceName, "|", sourceName);
110 }
111 } 88 }
112 89
113 // For anonymous directories, create the identifier. If this identifier already exists in the 90 // For anonymous directories, create the identifier. If this identifier already exists in the
@@ -126,7 +103,10 @@ namespace WixToolset.Core.ExtensibilityServices
126 var tuple = new DirectoryTuple(sourceLineNumbers, id) 103 var tuple = new DirectoryTuple(sourceLineNumbers, id)
127 { 104 {
128 ParentDirectoryRef = parentId, 105 ParentDirectoryRef = parentId,
129 DefaultDir = defaultDir, 106 Name = name,
107 ShortName = shortName,
108 SourceName = sourceName,
109 SourceShortName = shortSourceName
130 }; 110 };
131 111
132 section.Tuples.Add(tuple); 112 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
137 result.AssertSuccess(); 137 result.AssertSuccess();
138 138
139 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi"))); 139 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi")));
140 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\lowcab1.cab"))); 140 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\low1.cab")));
141 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); 141 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb")));
142 } 142 }
143 } 143 }
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 @@
10 <?elseif $(MediaTemplateCompressionLevel) = ""?> 10 <?elseif $(MediaTemplateCompressionLevel) = ""?>
11 <MediaTemplate /> 11 <MediaTemplate />
12 <?else?> 12 <?else?>
13 <MediaTemplate CabinetTemplate="lowcab{0}.cab" CompressionLevel="$(MediaTemplateCompressionLevel)" /> 13 <MediaTemplate CabinetTemplate="low{0}.cab" CompressionLevel="$(MediaTemplateCompressionLevel)" />
14 <?endif?> 14 <?endif?>
15 15
16 <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> 16 <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">