Skip to content

Add support for SDK Resolvers#2002

Merged
AndyGerlicher merged 1 commit into
dotnet:masterfrom
AndyGerlicher:sdkresolvers
Apr 25, 2017
Merged

Add support for SDK Resolvers#2002
AndyGerlicher merged 1 commit into
dotnet:masterfrom
AndyGerlicher:sdkresolvers

Conversation

@AndyGerlicher

@AndyGerlicher AndyGerlicher commented Apr 22, 2017

Copy link
Copy Markdown
Contributor

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:

  • Test on CoreCLR (haven't tried it yet).
  • Further testing within Visual Studio.
  • Load resolver(s) in a unit test (didn't have a good way to do this, may have to come later).

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial feedback on tests + interfaces only = "design feedback". Continuing to review for implementation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be named SdkReference to read more clearly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we get conceptual buy off on this from the people that vetoed it before?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this an input instead? (Can wait for a cleanup PR)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: writer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this approach. I'll send a commit to use xunit output capture.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can wait.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment copypasta

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably name this thing SdkResolverLoader.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FindResolvers()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, never mind. This is an internal implementation detail and is appropriately named.

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable overall.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a <remarks> describing what that means (searching in env var, next to MSBuild)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I get the name now. But I still don't like it. SdkResolvers?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting to ...Impl seems pretty wrong here. Why is it necessary?

@cdmihai cdmihai Apr 24, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still concerned about this. Does it represent a design flaw, or is it just an implementation fix we can deal with later?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This catch looks redundant with the overall one, except it doesn't rethrow? Just to avoid onion-peeling on resolver exceptions?

Comment thread src/Build/Evaluation/Evaluator.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so that makes the order I complained about above less relevant. Cool.

Comment thread src/Build/Evaluation/Evaluator.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit surprised to see this; I expected GetSdkPath to throw on failure.

Comment thread src/Framework/Sdk/ReferencedSdk.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Framework/Sdk/ReferencedSdk.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time I see this pattern I weep a bit. Where'd you get 397 from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffkl not sure. I think Resharper generated all of the IEquatable stuff.

Comment thread src/Framework/Sdk/SdkResolver.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: plurality disagreement

@cdmihai cdmihai Apr 24, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a thread safe Lazy?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importElementLocation makes it sound like SDKs can only come from msbuild import elements. Maybe SDKReferenceLocation would be a better name?

@livarcocc

Copy link
Copy Markdown
Contributor

@nguerrera

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this lead to re-logging the success results again? They also get logged at line 68

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, did not see the return on success.


In reply to: 113014254 [](ancestors = 113014254)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, did not see the return on success.


In reply to: 113016412 [](ancestors = 113016412)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I'd still convert the errors to messages if the log verbosity is diagnostic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if it's worth logging the resolver order when the log is diagnostic. Could be really helpful when debugging the resolver chain.

Comment thread src/Framework/Sdk/SdkResult.cs Outdated

@cdmihai cdmihai Apr 24, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stretegy typo

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Framework/Sdk/ReferencedSdk.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cdmihai cdmihai Apr 24, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who sets the default to None? The ProjectParser could do it when it hits real import elements.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AndyGerlicher AndyGerlicher force-pushed the sdkresolvers branch 3 times, most recently from 6749ad4 to c74c8e5 Compare April 25, 2017 02:34

@rainersigwald rainersigwald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only remaining major concern is the Impl cast, if it's a design flaw.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"will to"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make one of these hunks a \t, just for good measure?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still concerned about this. Does it represent a design flaw, or is it just an implementation fix we can deal with later?

Comment thread src/Framework/Sdk/SdkResolver.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SdkResultFactory?

@AndyGerlicher AndyGerlicher changed the base branch from master to preview/vs15.3 April 25, 2017 18:16
* 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
@AndyGerlicher AndyGerlicher changed the base branch from preview/vs15.3 to master April 25, 2017 18:34
@AndyGerlicher AndyGerlicher merged commit 9e22548 into dotnet:master Apr 25, 2017
@nguerrera

Copy link
Copy Markdown
Contributor

Let me know when packages are available and what version to use.

AndyGerlicher added a commit to AndyGerlicher/msbuild that referenced this pull request May 1, 2017
* 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
AndyGerlicher added a commit that referenced this pull request May 1, 2017
* This feature was regressed in #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 #2034
@AndyGerlicher AndyGerlicher deleted the sdkresolvers branch June 26, 2018 20:35
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

Successfully merging this pull request may close these issues.

7 participants