-
Notifications
You must be signed in to change notification settings - Fork 690
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
Remove unnecessary _MSBuildProjectReferenceExistent references #1001
Conversation
BuildProjectReferences=false; | ||
TargetFramework=$(TargetFramework); | ||
_ParentTargetFramework=$(TargetFramework); |
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.
This is better, but there is one case where you'll miss project references. If the project that is referred to is x-targeted and has project references conditioned on $(TargetFramework). If you want to see those, you need to evaluate with best compatible TFM, which the code I sent in email earlier would do. Given the urgency, I could understand worrying about that separately, but I suggest at least filing a bug to add a test for that case and deal with it. Conditional project references should be rare enough for this not to be high priority.
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.
Also, if you're depending on CustomAfterMicrosoftCommonTargets for this, you likely also need CustomAfterMicrosoftCommonCrossTargetingTargets (check spelling).
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.
We don't care about dependencies on the child projects.
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.
Ah, I misunderstood what this is doing. The only exposure would be if anything _AddMetadataToProjectReferences returned were conditional on TargetFramework, and from the list below that seems like a non-scenario. :)
<PackageId>$(PackageId)</PackageId>
<PackageVersion>$(PackageVersion)</PackageVersion>
<IncludeAssets>$(IncludeAssets)</IncludeAssets>
<ExcludeAssets>$(ExcludeAssets)</ExcludeAssets>
<PrivateAssets>$(PrivateAssets)</PrivateAssets>
FWIW, I was confused by the target name. From the POV of the project that actually executes the target, it has nothing to do with enumerating project references.
The point about CustomAfter for cross-targeting stands though. I think you would not get the data from x-targeted libs if that is how they get these targets. Actually, wouldn't they have them already though if they reference the SDK and wouldn't this cause duplicate imports?
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.
My suggestion to make this easier to follow would be:
- Don't pass the parent target framework back and forth, just add the target framework in the caller after you get the other data back.
- Rename _AddMetadataToProjectReferences to _GetPackageInfo or something and don't name the single item it returns _ProjectToProjectReferences.
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.
Ditto for IncludeAssets, ExcludeAssets, PrivateAssets: no need to pass them back and forth. Now that I've gone through this mental refactoring, I see all we really want from the reference that we don't already have are PackageId and PackageVersion. :)
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.
Strong agree with @nguerrera. This is basically:
projectReferences.Select(GetPackageInfo);
where
def GetPackageInfo(p):
projectInfo = new ProjectInfo(this.path)
projectInfo.PackageId = this.PackageId
projectInfo.PackageVersion = this.PackageVersion
return projectInfo
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.
After this review, let's sync up about changing these targets so they can work in parallel in a /m
build. But I think getting them right in this batched version first is good.
BuildProjectReferences=false; | ||
TargetFramework=$(TargetFramework); | ||
_ParentTargetFramework=$(TargetFramework); |
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.
Strong agree with @nguerrera. This is basically:
projectReferences.Select(GetPackageInfo);
where
def GetPackageInfo(p):
projectInfo = new ProjectInfo(this.path)
projectInfo.PackageId = this.PackageId
projectInfo.PackageVersion = this.PackageVersion
return projectInfo
<ExcludeAssets>none</ExcludeAssets> | ||
</_ProjectReferences> | ||
<_ProjectReferences Condition="'%(_ProjectReferences.PrivateAssets)' == ''"> | ||
<PrivateAssets>build,contentFiles,analyzers</PrivateAssets> |
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.
This should be a semi-colon delimited list
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.
Sure, the existing parsing code was expecting ,
, but I guess that is a vestige of project.json format.
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.
Fixed.
Having
_MSBuildProjectReferenceExistent
is incorrect since we use theProjectReference
set to get project references. We should only have batching operations%(...)
on a single project reference collection.Pass the parent project's TFM down to the client project as
_ParentTargetFramework
. I did this because the child project should not use this MSBuild property in conditionals.Fixes NuGet/Home#3865.
/cc @emgarten @mishra14 @nguerrera @rainersigwald