cake
cake copied to clipboard
Use OS-native directory separators in Path.FullPath
There are applications which do not understand the alternate directory separator; for example, https://github.com/cake-build/cake/issues/2337. There have also been multiple CLI tools I've used where I had to do .FullName.Replace('/', '\\')
.
Would you consider returning OS-native directory separators from Path.FullName
? It will just work in all situations, and it will not stand out and look strange on Windows any longer even when it does work.
(At times, I've manually edited MSBuild logs etc so people don't ask why I'm using weird paths.)
@jnm2 I would be OK with using System.IO.Path.DirectorySeparatorChar
as the separator (see https://github.com/cake-build/cake/blob/develop/src/Cake.Core/IO/Path.cs#L41), but I wonder how much work it would be and if this would bring any side effects with it. We would also need to fix tests.
Perhaps we could add an overload to FilePath and DirectoryPath to specify (non-UNC) path separators as well, for cases where you would want to use a non OS-native path separator?
public FilePath(string path, char separator) : base(path, separator) {
...
}
Just thinking out loud here.
Sweet! If I get to this before anyone else, I'll submit a PR that keeps the APIs the same and chooses System.IO.Path.DirectorySeparatorChar
. While fixing the tests, we can see what comes up?
I have also had challenges passing paths to other tools on Windows, that does not like the '/' separator. My thought was to add a method to FilePath and DirectoryPath with the "right" separators e.g. FullOsPath to not mess with expected outcome of FullPath?
I encountered an issue with NuSpecContent that requires OS-native directory-separator ('') when globbing. c:\foo**\bar.dll works, c:/foo/**/bar.dll does not