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

Provide ResolvedFrameworkReferences for VS to populate Solution Explorer #3355

Merged
merged 7 commits into from
Jun 28, 2019

Conversation

dsplaisted
Copy link
Member

No description provided.

@dsplaisted
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

Add ResolveFrameworkReferences target, rename ResolveTargetingPacks to ResolveTargetingPackAssets
Test case where targeting packs need to be downloaded
@dsplaisted dsplaisted force-pushed the process-frameworkreferences branch 2 times, most recently from 5062acd to eebffb7 Compare June 26, 2019 01:06
@dsplaisted dsplaisted marked this pull request as ready for review June 26, 2019 03:56
@dsplaisted
Copy link
Member Author

@drewnoakes @davkean Take a look at this PR and let me know if this matches what you were expecting based on our discussion.

ResolvedTargetingPacks="@(ResolvedTargetingPack)"
ResolvedRuntimePacks="@(ResolvedRuntimePack)">

<Output TaskParameter="ResolvedFrameworkReferences" ItemName="ResolvedFrameworkReference" />
Copy link
Member

Choose a reason for hiding this comment

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

What metadata does this item have?

Copy link
Member

@davkean davkean Jun 26, 2019

Choose a reason for hiding this comment

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

Ah, its here: https://github.com/dotnet/sdk/pull/3355/files#diff-6cfbacaa410e7ee1787b4771b158ded0. It was collapsed.

Yes, this appears to be what we want. We'll also want a ResolveFrameworkReferences in MSBuild proper so that we can call regardless of we're an SDK project or not.

Copy link
Member

Choose a reason for hiding this comment

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

Can you show me an example of one of these and we can decide what properties we want to show up?

to the assets file, and the ResolvePackageAssets target adds them to the TransitiveFrameworkReference
item. Here, we add them to FrameworkReference if they aren't already referenced.
============================================================
-->
<Target Name="AddTransitiveFrameworkReferences" AfterTargets="ResolvePackageAssets"
Copy link
Member

Choose a reason for hiding this comment

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

Will these appear as "ResolvedFrameworkReference"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be a problem if you end up with ResolvedFrameworkReference items that didn't have a corresponding FrameworkReference when you evaluated? Would you just ignore them or would it be a warning or error?

Copy link
Member

Choose a reason for hiding this comment

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

We will ignore them.

@drewnoakes
Copy link
Member

This looks great to me.

Seems the metadata on ResolvedFrameworkReference items will be:

  • OriginalItemSpec
  • TargetingPackPath
  • TargetingPackName
  • TargetingPackVersion
  • Profile
  • RuntimePackPath
  • RuntimePackName
  • RuntimePackVersion

I'm guessing we show all of these (maybe not OriginalItemSpec). Is that not the case?

The Dependencies node will also need IsImplicitlyDefined so we can control whether the reference can be removed in the UI.

@dsplaisted
Copy link
Member Author

Note that the runtime pack metadata won't be set unless the SelfContained property is true and the RuntimeIdentifier is set. So I'm not sure whether it's a good idea to show those properties in some cases but not others, or to just never show them at all.

packagesToDownload.Add(packageToDownload);
}
}
TaskItem resolvedFrameworkReference = new TaskItem(frameworkReference.ItemSpec);
Copy link
Member

Choose a reason for hiding this comment

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

We're expecting metadata (including IsImplicitlyDefined/PrivateAssets) to be copied from the original item -> resolved item, I think (?) this is what ResolveAssemblyReferences does.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would expect IsImplicitlyDefined to determine whether you can delete the reference from the solution tree, but what would you do with PrivateAssets?

Copy link
Member

Choose a reason for hiding this comment

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

It shows up in the Properties page so that you can flip it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I consider PrivateAssets on FrameworkReference items a user-facing feature. We use it to communicate that an implicit FrameworkReference is represented by the target framework, and thus doesn't need to flow transitively. I don't think there's a scenario for setting it on other FrameworkReferences, and if it shows up in the UI it's more likely to cause confusion and incorrect builds if people set it.

Copy link
Member

@davkean davkean Jun 27, 2019

Choose a reason for hiding this comment

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

You might have a reference to a project with a direct FrameworkReference and not want to inherit its FrameworkReference.

@drewnoakes
Copy link
Member

Currently assuming the properties are:

  • FrameworkReference

    • PrivateAssets
    • IsImplicitlyDefined (not visible)
  • ResolvedFrameworkReference

    • OriginalItemSpec
    • TargetingPackPath
    • TargetingPackName
    • TargetingPackVersion
    • Profile
    • PrivateAssets
    • IsImplicitlyDefined (not visible)

@davkean
Copy link
Member

davkean commented Jun 27, 2019

Can we have an example of these values? What exactly will TargetingPackName/Version give us that the path won't?

@dsplaisted
Copy link
Member Author

dsplaisted commented Jun 27, 2019

I will get examples later, but the name and version will be elements of the path. So they are to some degree redundant.

Also, just because we're setting a given piece of metadata on the ResolvedFrameworkReference items doesn't mean I think the value should necessarily be displayed. It just gives VS the flexibility to decide to display it if we think that's the right thing.

@drewnoakes
Copy link
Member

Agree. It'd be useful to see examples of these values so we can decide whether to remove any of the above properties.

@dsplaisted
Copy link
Member Author

Here's an example of what the ResolvedFrameworkReference items look like now:

ResolvedFrameworkReference
    Microsoft.NETCore.App
        IsImplicitlyDefined = true
        OriginalItemSpec = Microsoft.NETCore.App
        Profile = 
        RuntimePackName = Microsoft.NETCore.App.Runtime.win-x86
        RuntimePackPath = C:\Users\daplaist\.nuget\packages\microsoft.netcore.app.runtime.win-x86\3.0.0-preview7-27814-01
        RuntimePackVersion = 3.0.0-preview7-27814-01
        TargetingPackName = Microsoft.NETCore.App.Ref
        TargetingPackPath = C:\git\dotnet-sdk\.dotnet\packs\Microsoft.NETCore.App.Ref\3.0.0-preview7-27814-01
        TargetingPackVersion = 3.0.0-preview7-27814-01
    Microsoft.AspNetCore.App
        IsImplicitlyDefined = 
        OriginalItemSpec = Microsoft.AspNetCore.App
        Profile = 
        RuntimePackName = Microsoft.AspNetCore.App.Runtime.win-x86
        RuntimePackPath = C:\Users\daplaist\.nuget\packages\microsoft.aspnetcore.app.runtime.win-x86\3.0.0-preview7.19311.5
        RuntimePackVersion = 3.0.0-preview7.19311.5
        TargetingPackName = Microsoft.AspNetCore.App.Ref
        TargetingPackPath = C:\git\dotnet-sdk\.dotnet\packs\Microsoft.AspNetCore.App.Ref\3.0.0-preview7.19311.5
        TargetingPackVersion = 3.0.0-preview7.19311.5
    Microsoft.WindowsDesktop.App
        IsImplicitlyDefined = 
        OriginalItemSpec = Microsoft.WindowsDesktop.App
        Profile = 
        RuntimePackName = Microsoft.WindowsDesktop.App.Runtime.win-x86
        RuntimePackPath = C:\Users\daplaist\.nuget\packages\microsoft.windowsdesktop.app.runtime.win-x86\3.0.0-preview7-27814-01
        RuntimePackVersion = 3.0.0-preview7-27814-01
        TargetingPackName = Microsoft.WindowsDesktop.App.Ref
        TargetingPackPath = C:\git\dotnet-sdk\.dotnet\packs\Microsoft.WindowsDesktop.App.Ref\3.0.0-preview7-27814-01
        TargetingPackVersion = 3.0.0-preview7-27814-01

I'd suggest that the project system have a list of the metadata values to show, instead of a list that shouldn't be shown and showing everything else.

@drewnoakes
Copy link
Member

I'd suggest that the project system have a list of the metadata values to show, instead of a list that shouldn't be shown and showing everything else.

That's exactly what happens: https://github.com/dotnet/project-system/pull/4928/files#diff-5060c4224c575eb7de55c6c2353a0ac8

Are we sure that RuntimePackName or other runtime properties wouldn't be useful to see in the properties grid?

@davkean
Copy link
Member

davkean commented Jun 27, 2019

They only show up in certain situations, so it would be confused as to when they are populated vs. not.

Matches FrameworkReference items with KnownFrameworkReference items to determine the corresponding
targeting pack and if necessary the runtime pack. If the packs aren't available in the NetCoreTargetingPackRoot
folder, then generate PackageDownload items in order to download the packs during restore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding these. :)

@@ -50,6 +50,7 @@ public void The_design_time_build_succeeds_before_nuget_restore(string relativeP
var projectDirectory = Path.Combine(testAsset.TestRoot, relativeProjectPath);

var command = new MSBuildCommand(Log, "ResolveAssemblyReferencesDesignTime", projectDirectory);
command.WorkingDirectory = projectDirectory;
Copy link
Contributor

Choose a reason for hiding this comment

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

What happened here?

Copy link
Member Author

Choose a reason for hiding this comment

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

One of the args creates a binlog, so this ensures it goes to the right folder.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's not obvious. We should either make it so all tests can write binlogs or revert writing of binlog before committing. I don't want to see this spread.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also binlog writing is significantly slower and our tests are already slow.

resolvedFrameworkReference.SetMetadata("TargetingPackPath", targetingPack.GetMetadata(MetadataKeys.Path));
resolvedFrameworkReference.SetMetadata("TargetingPackName", targetingPack.GetMetadata(MetadataKeys.PackageName));
resolvedFrameworkReference.SetMetadata("TargetingPackVersion", targetingPack.GetMetadata(MetadataKeys.PackageVersion));
resolvedFrameworkReference.SetMetadata("Profile", targetingPack.GetMetadata("Profile"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming nit: Should this be TargetingPackProfile?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking about it, I think it makes slightly more sense as Profile than as TargetingPackProfile.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion, but why? The Profile has no meaning at runtime.

@dsplaisted dsplaisted merged commit ef7932d into dotnet:master Jun 28, 2019
dsplaisted pushed a commit to dsplaisted/sdk that referenced this pull request Feb 19, 2020
…0191029.1 (dotnet#3355)

- Microsoft.Build.Localization - 16.4.0-preview-19529-01
- Microsoft.Build - 16.4.0-preview-19529-01
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.

4 participants