-
Notifications
You must be signed in to change notification settings - Fork 588
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
DotNet take version into account when determining dotnet cli path #2220
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -487,9 +487,17 @@ module DotNet = | |
} | ||
static member Create() = { | ||
DotNetCliPath = | ||
let version = try Some <| getSDKVersionFromGlobalJson() with _ -> None | ||
findPossibleDotnetCliPaths None | ||
|> Seq.tryHead | ||
// shouldn't hit this one because the previous two probe PATH... | ||
|> Seq.tryFind (fun cliPath -> | ||
match version with | ||
| Some version -> | ||
version | ||
|> Path.combine "sdk" | ||
|> Path.combine (Path.getDirectory cliPath) | ||
|> Directory.Exists | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely an interesting approach. Do you think it is "OK" to have different behavior on CLI and fake running the command? Currently I think this should be opt-in but please feel free to tell me otherwise. But honestly I think this could "just work". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having different behavior on CLI and fake in certainly doesn't feel great, but in this case that should only ever occur when there is a I can't really imagine a case where it would cause trouble, but there are some cases where it would help the user not have to think about every aspect of how everything works, which I think is really one of the big strengths of Fake - some experienced people have made CI stuff much easier for less experienced people. I do see the point of having "no magic", but sometimes it conflicts with having very simple APIs, and my personal point of view is that there is a middle ground. I also see when trying to introduce Fake in my dayjob that these kind of details can make a big difference to getting new people excited about Fake. Opt-in? Could be a good way to do it, any idea how that could look? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It would be a simple I think in this case we might get away with this "magic" behavior if we properly document it. The only thing is if Microsoft decides to change their folder structure then this logic will obviously break apart. We depend on internals here and if it breaks it will probably be hard to detect and someone needs to understand the new system and implement it (and chances are that's me unfortunately ;) ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I've been a little inactive here, but I've had the chance to think a little about this. I totally understand your point of view, I'm just wondering if this is really adding any value - if the user already has to specify an option it would be just as easy to specify the install location provided by the install step, wouldn't it? My suggestion is we just close this, then :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @severisv I think I'll leave that up to you, if you think this is valuable to get in, please fix the first comment and add some documentation around the behavior change and I'll merge this. If we merge this an people are caught off-guard by this we can still change the behavior back ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made the change you suggested (hopefully) :) You also said to document it well, where and how do I document it exactly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea where this would fit, I guess the release notes are the way to go for now. |
||
| None -> true | ||
) | ||
|> Option.defaultWith (fun () -> if Environment.isUnix then "dotnet" else "dotnet.exe") | ||
WorkingDirectory = Directory.GetCurrentDirectory() | ||
CustomParams = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually I don't like
with _ -> None
if some parsing error occurs I want the exception to be thrown or have a warningThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely agree. It's just that
getSDKVersionFromGlobalJson
fails whenglobal.json
is not present, which won't work here.I didn't want to make a bigger change until the idea was verified, but I suppose having
getSDKVersionFromGlobalJson
returnNone
when there is noglobal.json
and fail otherwise would make sense?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes or we could introduce a
tryGetSDKVersionFromGlobalJson
if it doesn't already exist. This would only throw when the file exists and we have some parsing problem and otherwise returnSome
orNone