Add support for SDK Resolvers#2002
Conversation
2297ba3 to
b9aa944
Compare
rainersigwald
left a comment
There was a problem hiding this comment.
Partial feedback on tests + interfaces only = "design feedback". Continuing to review for implementation.
There was a problem hiding this comment.
I think this should be named SdkReference to read more clearly.
There was a problem hiding this comment.
Did we get conceptual buy off on this from the people that vetoed it before?
There was a problem hiding this comment.
Make this an input instead? (Can wait for a cleanup PR)
There was a problem hiding this comment.
Not a fan of this approach. I'll send a commit to use xunit output capture.
There was a problem hiding this comment.
Can wait, but: I don't think this is the right logging strategy. We should look at how NuGet handles multiple package sources and learn from their experience/mistakes. I think we should log every message from all resolvers but demote ERROR to INFO--otherwise, how will we diagnose the situation "the first resolver was supposed to resolve this but didn't"?
There was a problem hiding this comment.
I'd probably name this thing SdkResolverLoader.
There was a problem hiding this comment.
Ah, never mind. This is an internal implementation detail and is appropriately named.
rainersigwald
left a comment
There was a problem hiding this comment.
Seems reasonable overall.
There was a problem hiding this comment.
Add a <remarks> describing what that means (searching in env var, next to MSBuild)?
There was a problem hiding this comment.
I really hope we can come up with a better implementation here but we can always ignore this field in the future so it should be reasonably harmless.
There was a problem hiding this comment.
Oh, I get the name now. But I still don't like it. SdkResolvers?
There was a problem hiding this comment.
Casting to ...Impl seems pretty wrong here. Why is it necessary?
There was a problem hiding this comment.
Same. All usages of result in this method should be of the supertype members. The Resolver could even choose not to use the resultFactory and use its own result implementation :)
In reply to: 112969534 [](ancestors = 112969534)
There was a problem hiding this comment.
Still concerned about this. Does it represent a design flaw, or is it just an implementation fix we can deal with later?
There was a problem hiding this comment.
This catch looks redundant with the overall one, except it doesn't rethrow? Just to avoid onion-peeling on resolver exceptions?
There was a problem hiding this comment.
Ah, so that makes the order I complained about above less relevant. Cool.
There was a problem hiding this comment.
I was a bit surprised to see this; I expected GetSdkPath to throw on failure.
There was a problem hiding this comment.
We decided to be case-sensitive for Sdk names? I think we did as a side effect of the initial implementation on case-sensitive file systems, but I don't remember for sure. Should be doc'ed either way.
There was a problem hiding this comment.
Every time I see this pattern I weep a bit. Where'd you get 397 from?
There was a problem hiding this comment.
@jeffkl not sure. I think Resharper generated all of the IEquatable stuff.
There was a problem hiding this comment.
typo: plurality disagreement
There was a problem hiding this comment.
We'll have to come up with a better prioritization scheme for 3rd party support. Even if we do not expect many resolver implementations, there still will be some, and we can't go with a global registry of priorities. :)
There was a problem hiding this comment.
Why not a thread safe Lazy?
There was a problem hiding this comment.
importElementLocation makes it sound like SDKs can only come from msbuild import elements. Maybe SDKReferenceLocation would be a better name?
There was a problem hiding this comment.
doesn't this lead to re-logging the success results again? They also get logged at line 68
There was a problem hiding this comment.
There was a problem hiding this comment.
I'd log errors only when:
- there was no successful resolver
- there was at least one successful resolver and the log verbosity is diagnostic. And in this case I'd maybe convert the errors to warnings / messages so they don't fail the build.
There was a problem hiding this comment.
There was a problem hiding this comment.
However, I'd still log errors when verbosity is diagnostic. To help users debug all resolvers and understand why a certain one did not work.
In reply to: 113016807 [](ancestors = 113016807,113016412)
There was a problem hiding this comment.
Though I'd still convert the errors to messages if the log verbosity is diagnostic.
There was a problem hiding this comment.
Wonder if it's worth logging the resolver order when the log is diagnostic. Could be really helpful when debugging the resolver chain.
There was a problem hiding this comment.
Since the SdkResultFactory mentions warnings and errors, maybe the SdkResult should do to. Either via Warning / Error properties, or a Diagnostic list, where the Diagnostic.Type is either Warning / Error. This way you could avoid casting to the implementation.
There was a problem hiding this comment.
Should the default resolver only get added when there are no explicit resolvers set?
If the default is there all the time, it means it might work when the build should actually fail. Maybe the SdkResult should contain a ShouldFailTheBuild member.
There was a problem hiding this comment.
What about the range syntax (e.g.FooSDK/min:3.4)? I guess MSBuild should be doing that, otherwise all resolvers would duplicate the logic.
There was a problem hiding this comment.
Who sets the default to None? The ProjectParser could do it when it hits real import elements.
There was a problem hiding this comment.
What if, the ProjectSdkElement has a condition on it? The ProjectElementContainer allows for it. Then, imports that are placed above an Sdk element might affect that condition via conditions / file system side effects.
6749ad4 to
c74c8e5
Compare
rainersigwald
left a comment
There was a problem hiding this comment.
Only remaining major concern is the Impl cast, if it's a design flaw.
There was a problem hiding this comment.
Can you make one of these hunks a \t, just for good measure?
There was a problem hiding this comment.
Still concerned about this. Does it represent a design flaw, or is it just an implementation fix we can deal with later?
d8d7501 to
3d1fa75
Compare
* Adds support for MSBuild to discover plug-in based resolvers for the
'SDK' import feature. A resolver assembly can be placed in:
MSBuild\SdkResolver\(ResolverName)\(ResolverName).dll
MSBuild will create an instance of any class that implements SdkResolver
and attempt to resolve all SDK references with those resolver (sorted by
SdkResolver.Priority).
* Adds support for MSBuild to consume an Sdk reference as element (as an
alternative to a property on the Project element). Both versions of the
syntax will add an implicit Import element at the top and the bottom of
the file.
Related to dotnet#1493
3d1fa75 to
b0a6d07
Compare
|
Let me know when packages are available and what version to use. |
* This feature was regressed in dotnet#2002 * Update unit tests to verify functionality * Update ProjectParser to parse SDK name/version values and construct an SdkReference object to be used by the evaluator. Closes dotnet#2034
Sending the PR for some initial feedback. I haven't reviewed it as carefully as I'd like (I'm sure there are nit items), and things I know I still have left to do: