Skip to content

Commit 979a47d

Browse files
TheCakeIsNaOHgep13
authored andcommitted
(#502) Fix path separator in nuspec file element
Converts the path separator character in the nuspec file source to the character that is correct for the OS that is running the packing operation. Changes "\" to "/" on Linux and MacOS systems, and changes "/" to "\" on Windows systems. Fixes: chocolatey/choco#502
1 parent bedcd19 commit 979a47d

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Core/Authoring/ManifestReader.cs

+14-6
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private static ManifestMetadata ReadMetadata(XElement xElement)
6464
return manifestMetadata;
6565
}
6666

67-
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
67+
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
6868
private static void ReadMetadataValue(ManifestMetadata manifestMetadata, XElement element, HashSet<string> allElements)
6969
{
7070
if (element.Value == null)
@@ -151,10 +151,10 @@ private static void ReadMetadataValue(ManifestMetadata manifestMetadata, XElemen
151151
break;
152152
case "conflicts":
153153
manifestMetadata.Conflicts = value;
154-
break;
154+
break;
155155
case "softwareDisplayName":
156156
manifestMetadata.SoftwareDisplayName = value;
157-
break;
157+
break;
158158
case "softwareDisplayVersion":
159159
manifestMetadata.SoftwareDisplayVersion = value;
160160
break;
@@ -274,7 +274,7 @@ private static List<ManifestDependencySet> ReadDependencySets(XElement dependenc
274274
return new List<ManifestDependencySet>();
275275
}
276276

277-
// Disallow the <dependencies> element to contain both <dependency> and
277+
// Disallow the <dependencies> element to contain both <dependency> and
278278
// <group> child elements. Unfortunately, this cannot be enforced by XSD.
279279
if (dependenciesElement.ElementsNoNamespace("dependency").Any() &&
280280
dependenciesElement.ElementsNoNamespace("group").Any())
@@ -340,9 +340,17 @@ private static List<ManifestFile> ReadFilesList(XElement xElement)
340340
string target = file.GetOptionalAttributeValue("target").SafeTrim();
341341
string exclude = file.GetOptionalAttributeValue("exclude").SafeTrim();
342342

343-
// Multiple sources can be specified by using semi-colon separated values.
343+
char separator = Path.DirectorySeparatorChar;
344+
345+
// Multiple sources can be specified by using semi-colon separated values.
344346
files.AddRange(from source in srcElement.Value.Trim(';').Split(';')
345-
select new ManifestFile { Source = source.SafeTrim(), Target = target.SafeTrim(), Exclude = exclude.SafeTrim() });
347+
select new ManifestFile
348+
{
349+
// Replace directory separator in the file src element to the one that is correct for the OS of the packing system.
350+
Source = source.SafeTrim().Replace('/', separator).Replace('\u005c', separator),
351+
Target = target.SafeTrim(),
352+
Exclude = exclude.SafeTrim()
353+
});
346354
}
347355
return files;
348356
}

0 commit comments

Comments
 (0)