Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@@ path.combine strips root markers from path2, why? #670

Closed
sillyotter opened this issue Mar 2, 2015 · 3 comments
Closed

@@ path.combine strips root markers from path2, why? #670

sillyotter opened this issue Mar 2, 2015 · 3 comments

Comments

@sillyotter
Copy link
Contributor

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?

@forki
Copy link
Member

forki commented Mar 11, 2015

could you please add test cases and fix the behaviour?

@sillyotter
Copy link
Contributor Author

I believe so. I'll have a pull request shortly. Pull Request #692 should fix this.

@sillyotter
Copy link
Contributor Author

Pull request #695 adds a new non trimming route to Path.Combine and an operator </> to access it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants