You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In dealing with a fake script that I want to run on both Windows and Linux I discovered that the @@ operator runs differently on the two different platforms.
The code in question is the combinePaths function.
The combinePaths function is mostly a simple wrapper around Path.Combine but adds some extra stripping operations in to path2 that causes it to behave differently on the two different platforms. Specifically, if you look at the docs for Path.Combine, it says:
If path2 does not include a root (for example, if path2 does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If path2 includes a root, path2 is returned.
if path2 includes a root, path2 is returned. In my case, I've got a bit of code that says "src" @@ folderName (its actually in the genFSAssemblyInfo of a FSharpProjectScaffold build.fsx file.) On a windows box, folderName is a full path, "C:\Projects\Something". "src" @@ "C:\Projects\Something" returns "C:\Projects\Something" as expected. Calling Path.Combine in mono with "src" and "/home/projects/something" returns "/home/projects/something" just as it is expect to from the docs. But, the combinePaths function in FAKE is stripping off the linux root / from the second path, resulting in the local path "src/home/projects/something"
The underlying Path.Combine methods seem to do what they are supposed to, why does Fake change that behavior with the extra trim operations? And can it be fixed to make both environments work the same?
The text was updated successfully, but these errors were encountered:
In dealing with a fake script that I want to run on both Windows and Linux I discovered that the @@ operator runs differently on the two different platforms.
The code in question is the combinePaths function.
The combinePaths function is mostly a simple wrapper around Path.Combine but adds some extra stripping operations in to path2 that causes it to behave differently on the two different platforms. Specifically, if you look at the docs for Path.Combine, it says:
if path2 includes a root, path2 is returned. In my case, I've got a bit of code that says "src" @@ folderName (its actually in the genFSAssemblyInfo of a FSharpProjectScaffold build.fsx file.) On a windows box, folderName is a full path, "C:\Projects\Something". "src" @@ "C:\Projects\Something" returns "C:\Projects\Something" as expected. Calling Path.Combine in mono with "src" and "/home/projects/something" returns "/home/projects/something" just as it is expect to from the docs. But, the combinePaths function in FAKE is stripping off the linux root / from the second path, resulting in the local path "src/home/projects/something"
The underlying Path.Combine methods seem to do what they are supposed to, why does Fake change that behavior with the extra trim operations? And can it be fixed to make both environments work the same?
The text was updated successfully, but these errors were encountered: