-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add NormalizePath() to IntrinsicFunctions #1405
Conversation
…d as Path.Combine()
|
Excellent question. If you pass it an empty string, you get an error during your build:
If you have invalid characters you get this:
Invalid UNC path:
Long path:
Do the errors seem like they are a good user experience? |
@jeffkl put a non-digit character in there--we may be trying to coerce it to an int or something? |
We should just rely on the runtime to say "The specified file name or path is too long, or a component of the specified path is too long."
Okay I fixed the PathTooLongException message so now it says:
|
A number doesn't appear to matter: <Message Text="Result: '$([MSBuild]::NormalizePath(123))'" />
Anything else I should try? |
@AArnott hate to bother you, do you know why GitVersioning would crash like this? It only happens in our CI environment and I can't get it to repro locally. Before I spent any time looking into it I figured I'd ping you just in case you knew what the problem is or where to start. |
@jeffkl: my best guess, since the failure is deep within libgit2sharp in reading a tree object, is that the git commit is corrupted/invalid, or that the server didn't initialize the .git directory correctly. |
@AArnott thanks a lot, I'll see what I can figure out. |
@AArnott I was able to figure out that our CI build definition changed recently to do a shallow clone and so GitVersioning obviously wouldn't be able to calculate commit height. I changed the setting back in the build definition and everything is working again. Just a heads up in case anyone else hits the issue. Thanks again for pointing me in a direction. |
@dotnet-bot test Windows_NT Build for Desktop please |
Treats the path as a directory and ensures a trailing slash. Empty input means empty output instead of an error.
I decided to add a NormalizeDirectory() as well which can be used to combine, normalize, and ensure a trailing slash. Passing in an empty directory will return String.Empty rather than throwing an error. |
@jeffkl Thanks for letting me know what it was. NB.GV does document that shallow cloning isn't supported, but it would be interesting for me to test this further so that instead of a strange failure like this it could give a more helpful message to reduce time like yours spent investigating. I've filed dotnet/Nerdbank.GitVersioning#92 to track. |
Rather than just "fix" the file path, this normalizes it and fixes the directory separators. I did not make a unit test because
FileUtilities.NormalizePath()
is well tested.Closes #55