Skip to content
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

Merged
merged 1 commit into from
Nov 8, 2016
Merged

Remove unnecessary _MSBuildProjectReferenceExistent references #1001

merged 1 commit into from
Nov 8, 2016

Conversation

joelverhagen
Copy link
Member

@joelverhagen joelverhagen commented Nov 4, 2016

Having _MSBuildProjectReferenceExistent is incorrect since we use the ProjectReference 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

BuildProjectReferences=false;
TargetFramework=$(TargetFramework);
_ParentTargetFramework=$(TargetFramework);

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.

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

Copy link
Member Author

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.

Copy link

@nguerrera nguerrera Nov 5, 2016

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?

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:

  1. 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.
  2. Rename _AddMetadataToProjectReferences to _GetPackageInfo or something and don't name the single item it returns _ProjectToProjectReferences.

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

Copy link
Contributor

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

Copy link
Contributor

@rainersigwald rainersigwald left a 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);
Copy link
Contributor

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>
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@joelverhagen joelverhagen merged commit 07a6ea2 into NuGet:dev Nov 8, 2016
@joelverhagen joelverhagen deleted the jver/3865 branch November 8, 2016 20:18
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.

6 participants