aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Compiler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Compiler.cs')
-rw-r--r--src/WixToolset.Core/Compiler.cs124
1 files changed, 25 insertions, 99 deletions
diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs
index 4d0e608b..b29821b0 100644
--- a/src/WixToolset.Core/Compiler.cs
+++ b/src/WixToolset.Core/Compiler.cs
@@ -300,24 +300,6 @@ namespace WixToolset.Core
300 } 300 }
301 301
302 /// <summary> 302 /// <summary>
303 /// Given a possible short and long file name, create an msi filename value.
304 /// </summary>
305 /// <param name="shortName">The short file name.</param>
306 /// <param name="longName">Possibly the long file name.</param>
307 /// <returns>The value in the msi filename data type.</returns>
308 private string GetMsiFilenameValue(string shortName, string longName)
309 {
310 if (null != shortName && null != longName && !String.Equals(shortName, longName, StringComparison.OrdinalIgnoreCase))
311 {
312 return String.Concat(shortName, "|", longName);
313 }
314 else
315 {
316 return this.Core.IsValidShortFilename(longName, false) ? longName : shortName;
317 }
318 }
319
320 /// <summary>
321 /// Adds a search property to the active section. 303 /// Adds a search property to the active section.
322 /// </summary> 304 /// </summary>
323 /// <param name="sourceLineNumbers">Current source/line number of processing.</param> 305 /// <param name="sourceLineNumbers">Current source/line number of processing.</param>
@@ -3036,12 +3018,6 @@ namespace WixToolset.Core
3036 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "DestinationProperty", "DestinationDirectory")); 3018 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "DestinationProperty", "DestinationDirectory"));
3037 } 3019 }
3038 3020
3039 // generate a short file name
3040 if (null == destinationShortName && (null != destinationName && !this.Core.IsValidShortFilename(destinationName, false)))
3041 {
3042 destinationShortName = this.Core.CreateShortName(destinationName, true, false, node.Name.LocalName, componentId);
3043 }
3044
3045 if (null == id) 3021 if (null == id)
3046 { 3022 {
3047 id = this.Core.CreateIdentifier("cf", sourceFolder, sourceDirectory, sourceProperty, destinationDirectory, destinationProperty, destinationName); 3023 id = this.Core.CreateIdentifier("cf", sourceFolder, sourceDirectory, sourceProperty, destinationDirectory, destinationProperty, destinationName);
@@ -3063,7 +3039,8 @@ namespace WixToolset.Core
3063 { 3039 {
3064 ComponentRef = componentId, 3040 ComponentRef = componentId,
3065 SourceName = sourceName, 3041 SourceName = sourceName,
3066 DestName= String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName), 3042 DestinationName = destinationName,
3043 DestinationShortName = destinationShortName,
3067 SourceFolder = sourceDirectory ?? sourceProperty, 3044 SourceFolder = sourceDirectory ?? sourceProperty,
3068 DestFolder = destinationDirectory ?? destinationProperty, 3045 DestFolder = destinationDirectory ?? destinationProperty,
3069 Delete = delete, 3046 Delete = delete,
@@ -3108,7 +3085,8 @@ namespace WixToolset.Core
3108 { 3085 {
3109 ComponentRef = componentId, 3086 ComponentRef = componentId,
3110 FileRef = fileId, 3087 FileRef = fileId,
3111 DestinationName = String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName), 3088 DestinationName = destinationName,
3089 DestinationShortName = destinationShortName,
3112 DestinationFolder = destinationDirectory ?? destinationProperty, 3090 DestinationFolder = destinationDirectory ?? destinationProperty,
3113 }); 3091 });
3114 } 3092 }
@@ -4184,16 +4162,12 @@ namespace WixToolset.Core
4184 { 4162 {
4185 if (String.IsNullOrEmpty(shortName)) 4163 if (String.IsNullOrEmpty(shortName))
4186 { 4164 {
4187 if (!name.Equals(".") && !name.Equals("SourceDir") && !this.Core.IsValidShortFilename(name, false))
4188 {
4189 shortName = this.Core.CreateShortName(name, false, false, "Directory", parentId);
4190 }
4191 } 4165 }
4192 else if (name.Equals(".")) 4166 else if (name == ".")
4193 { 4167 {
4194 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "ShortName", "Name", name)); 4168 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "ShortName", "Name", name));
4195 } 4169 }
4196 else if (name.Equals(shortName)) 4170 else if (name.Equals(shortName, StringComparison.OrdinalIgnoreCase))
4197 { 4171 {
4198 this.Core.Write(WarningMessages.DirectoryRedundantNames(sourceLineNumbers, node.Name.LocalName, "Name", "ShortName", name)); 4172 this.Core.Write(WarningMessages.DirectoryRedundantNames(sourceLineNumbers, node.Name.LocalName, "Name", "ShortName", name));
4199 } 4173 }
@@ -4210,16 +4184,12 @@ namespace WixToolset.Core
4210 { 4184 {
4211 if (String.IsNullOrEmpty(shortSourceName)) 4185 if (String.IsNullOrEmpty(shortSourceName))
4212 { 4186 {
4213 if (!sourceName.Equals(".") && !this.Core.IsValidShortFilename(sourceName, false))
4214 {
4215 shortSourceName = this.Core.CreateShortName(sourceName, false, false, "Directory", parentId);
4216 }
4217 } 4187 }
4218 else if (sourceName.Equals(".")) 4188 else if (sourceName == ".")
4219 { 4189 {
4220 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "ShortSourceName", "SourceName", sourceName)); 4190 this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "ShortSourceName", "SourceName", sourceName));
4221 } 4191 }
4222 else if (sourceName.Equals(shortSourceName)) 4192 else if (sourceName.Equals(shortSourceName, StringComparison.OrdinalIgnoreCase))
4223 { 4193 {
4224 this.Core.Write(WarningMessages.DirectoryRedundantNames(sourceLineNumbers, node.Name.LocalName, "SourceName", "ShortSourceName", sourceName)); 4194 this.Core.Write(WarningMessages.DirectoryRedundantNames(sourceLineNumbers, node.Name.LocalName, "SourceName", "ShortSourceName", sourceName));
4225 } 4195 }
@@ -5463,7 +5433,6 @@ namespace WixToolset.Core
5463 var defaultSize = 0; 5433 var defaultSize = 0;
5464 string defaultVersion = null; 5434 string defaultVersion = null;
5465 string fontTitle = null; 5435 string fontTitle = null;
5466 var generatedShortFileName = false;
5467 var keyPath = YesNoType.NotSet; 5436 var keyPath = YesNoType.NotSet;
5468 string name = null; 5437 string name = null;
5469 var patchGroup = CompilerConstants.IntegerNotSet; 5438 var patchGroup = CompilerConstants.IntegerNotSet;
@@ -5686,16 +5655,22 @@ namespace WixToolset.Core
5686 } 5655 }
5687 } 5656 }
5688 5657
5689 // generate a short file name 5658 if (name == null)
5690 if (null == shortName && (null != name && !this.Core.IsValidShortFilename(name, false)))
5691 { 5659 {
5692 shortName = this.Core.CreateShortName(name, true, false, node.Name.LocalName, directoryId); 5660 if (shortName == null)
5693 generatedShortFileName = true; 5661 {
5662 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
5663 }
5664 else
5665 {
5666 name = shortName;
5667 shortName = null;
5668 }
5694 } 5669 }
5695 5670
5696 if (null == id) 5671 if (null == id)
5697 { 5672 {
5698 id = this.Core.CreateIdentifier("fil", directoryId, name ?? shortName); 5673 id = this.Core.CreateIdentifier("fil", directoryId, name);
5699 } 5674 }
5700 5675
5701 if (null != defaultVersion && null != companionFile) 5676 if (null != defaultVersion && null != companionFile)
@@ -5811,11 +5786,11 @@ namespace WixToolset.Core
5811 5786
5812 if (String.IsNullOrEmpty(source)) 5787 if (String.IsNullOrEmpty(source))
5813 { 5788 {
5814 source = name ?? shortName; 5789 source = name;
5815 } 5790 }
5816 else if (source.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) // if source relies on parent directories, append the file name 5791 else if (source.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) // if source relies on parent directories, append the file name
5817 { 5792 {
5818 source = null == name ? Path.Combine(source, shortName) : Path.Combine(source, name); 5793 source = Path.Combine(source, name);
5819 } 5794 }
5820 5795
5821 var attributes = FileSymbolAttributes.None; 5796 var attributes = FileSymbolAttributes.None;
@@ -5826,7 +5801,6 @@ namespace WixToolset.Core
5826 attributes |= checksum ? FileSymbolAttributes.Checksum : 0; 5801 attributes |= checksum ? FileSymbolAttributes.Checksum : 0;
5827 attributes |= compressed.HasValue && compressed == true ? FileSymbolAttributes.Compressed : 0; 5802 attributes |= compressed.HasValue && compressed == true ? FileSymbolAttributes.Compressed : 0;
5828 attributes |= compressed.HasValue && compressed == false ? FileSymbolAttributes.Uncompressed : 0; 5803 attributes |= compressed.HasValue && compressed == false ? FileSymbolAttributes.Uncompressed : 0;
5829 attributes |= generatedShortFileName ? FileSymbolAttributes.GeneratedShortFileName : 0;
5830 5804
5831 this.Core.AddSymbol(new FileSymbol(sourceLineNumbers, id) 5805 this.Core.AddSymbol(new FileSymbol(sourceLineNumbers, id)
5832 { 5806 {
@@ -5838,14 +5812,6 @@ namespace WixToolset.Core
5838 Language = defaultLanguage, 5812 Language = defaultLanguage,
5839 Attributes = attributes, 5813 Attributes = attributes,
5840 5814
5841 //ReadOnly = readOnly,
5842 //Hidden = hidden,
5843 //System = system,
5844 //Vital = vital,
5845 //Checksum = checksum,
5846 //Compressed = compressed,
5847 //GeneratedShortFileName = generatedShortFileName,
5848
5849 DirectoryRef = directoryId, 5815 DirectoryRef = directoryId,
5850 DiskId = (CompilerConstants.IntegerNotSet == diskId) ? null : (int?)diskId, 5816 DiskId = (CompilerConstants.IntegerNotSet == diskId) ? null : (int?)diskId,
5851 Source = new IntermediateFieldPathValue { Path = source }, 5817 Source = new IntermediateFieldPathValue { Path = source },
@@ -6454,28 +6420,6 @@ namespace WixToolset.Core
6454 { 6420 {
6455 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); 6421 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
6456 } 6422 }
6457 else if (0 < name.Length)
6458 {
6459 if (this.Core.IsValidShortFilename(name, false))
6460 {
6461 if (null == shortName)
6462 {
6463 shortName = name;
6464 name = null;
6465 }
6466 else
6467 {
6468 this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Name", name, "ShortName"));
6469 }
6470 }
6471 else // generate a short file name.
6472 {
6473 if (null == shortName)
6474 {
6475 shortName = this.Core.CreateShortName(name, true, false, node.Name.LocalName, componentId);
6476 }
6477 }
6478 }
6479 6423
6480 if (null == section) 6424 if (null == section)
6481 { 6425 {
@@ -6493,7 +6437,8 @@ namespace WixToolset.Core
6493 { 6437 {
6494 this.Core.AddSymbol(new IniFileSymbol(sourceLineNumbers, id) 6438 this.Core.AddSymbol(new IniFileSymbol(sourceLineNumbers, id)
6495 { 6439 {
6496 FileName = this.GetMsiFilenameValue(shortName, name), 6440 FileName = name,
6441 ShortFileName = shortName,
6497 DirProperty = directory, 6442 DirProperty = directory,
6498 Section = section, 6443 Section = section,
6499 Key = key, 6444 Key = key,
@@ -6585,25 +6530,6 @@ namespace WixToolset.Core
6585 { 6530 {
6586 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); 6531 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
6587 } 6532 }
6588 else if (0 < name.Length)
6589 {
6590 if (this.Core.IsValidShortFilename(name, false))
6591 {
6592 if (null == shortName)
6593 {
6594 shortName = name;
6595 name = null;
6596 }
6597 else
6598 {
6599 this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Name", name, "ShortName"));
6600 }
6601 }
6602 else if (null == shortName) // generate a short file name.
6603 {
6604 shortName = this.Core.CreateShortName(name, true, false, node.Name.LocalName);
6605 }
6606 }
6607 6533
6608 if (null == section) 6534 if (null == section)
6609 { 6535 {
@@ -6677,8 +6603,8 @@ namespace WixToolset.Core
6677 { 6603 {
6678 var symbol = this.Core.AddSymbol(new IniLocatorSymbol(sourceLineNumbers, id) 6604 var symbol = this.Core.AddSymbol(new IniLocatorSymbol(sourceLineNumbers, id)
6679 { 6605 {
6680 SignatureRef = id.Id, 6606 FileName = name,
6681 FileName = this.GetMsiFilenameValue(shortName, name), 6607 ShortFileName = shortName,
6682 Section = section, 6608 Section = section,
6683 Key = key, 6609 Key = key,
6684 Type = type 6610 Type = type