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

DTB only returns top-level package references #11358

Merged

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Apr 21, 2020

Historically the full graph of package references has been returned in design-time builds and used to populate the Dependencies node in Solution Explorer.

This graph can be very large. Many sessions won't expand the Dependencies node, so we would like to avoid this up-front cost during solution load. This will be achieved by lazily retrieving transitive dependency information from the assets file directly when needed.

This PR modifies PreprocessPackageDependenciesDesignTime in the following ways:

  • Only return items of type Package (exclude others like diagnostics, targets, assemblies)
  • Don't return items for all target (only those in the current target framework are required, as we run a DTB per target)
  • Simplify the IDs used for returned items to reduce allocations and simplify processing on the Project System side
  • Remove intermediate objects (via the private ItemMetadata type hierarchy) to reduce allocations

The corresponding Project System changes are able to identify when the SDK is operating with this new behaviour or the old (legacy) behaviour and adapt accordingly.


Questions:

In Microsoft.PackageDependencyResolution.targets:

  1. Can we remove the ReportAssetsLogMessages task? It no longer seems necessary for our purposes, but someone theoretically may depend upon it.

  2. In this task, outputs TargetDefinitions, FileDefinitions and FileDependencies appear to be no longer used. Again, is it safe to remove them and the code that allocates them?

    <ResolvePackageDependencies
      ProjectPath="$(MSBuildProjectFullPath)"
      ProjectAssetsFile="$(ProjectAssetsFile)"
      ProjectLanguage="$(Language)"
      ContinueOnError="ErrorAndContinue">
      <Output TaskParameter="TargetDefinitions" ItemName="TargetDefinitions" />
      <Output TaskParameter="PackageDefinitions" ItemName="PackageDefinitions" />
      <Output TaskParameter="FileDefinitions" ItemName="FileDefinitions" />
      <Output TaskParameter="PackageDependencies" ItemName="PackageDependencies" />
      <Output TaskParameter="FileDependencies" ItemName="FileDependencies" />
    </ResolvePackageDependencies>

Copy link

@wli3 wli3 left a comment

Choose a reason for hiding this comment

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

Some nit in the beginning. And then I am lost at 1baaca2 .

Looks like tests are start from fresh. So I don't know what is actually removed. We should fine a time to look into this change together

Copy link

@wli3 wli3 left a comment

Choose a reason for hiding this comment

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

Had an about 1 hour meeting with Drew. Now I understand this change. The only consumer of this code is project system. So removing all these information should be safe. The code left is also straightforward. The new tests around the code are also sufficient to cover and to understand what the code is doing.

@wli3
Copy link

wli3 commented May 7, 2020

@dsplaisted do you want to have a look at this PR since this it is rather big? I think it is good after talking to Drew. We plan to merge this in a day so we have more time for an another team

@wli3
Copy link

wli3 commented May 8, 2020

Just learnt Daniel is OOF today. Could we wait until end of the Friday?

@dsplaisted
Copy link
Member

We should also update the minimum MSBuild version to 16.7 for this release, right?

Copy link
Member

@dsplaisted dsplaisted left a comment

Choose a reason for hiding this comment

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

Looks good.

Should we also update the minimum MSBuild version to 16.7 for this release? Otherwise using this SDK with an older VS will have a broken dependency tree, right?

To Drew's questions:

Let's remove the ReportAssetsLogMessages task.

I think the TargetDefinitions, FileDefinitions, and FileDependencies may be used by some of our build infrastructure (in dotnet/installer, for example). However, I would propose that by default we don't produce them, with a flag that can be used to turn them back on.

@KathleenDollard, the two previous changes are ones we should track / document as part of our "possibly breaking changes for MSBuild logic" process.

drewnoakes added a commit to drewnoakes/toolset that referenced this pull request May 11, 2020
Changes to the design-time build targets used to populate the dependency node mean that this SDK will only work with VS 16.7 or later.

See dotnet/sdk#11358
@drewnoakes drewnoakes force-pushed the design-time-package-references branch from 26f3e8f to 17c60d0 Compare May 11, 2020 06:04
@drewnoakes
Copy link
Member Author

drewnoakes commented May 11, 2020

@dsplaisted thanks for your review.

Should we also update the minimum MSBuild version to 16.7 for this release? Otherwise using this SDK with an older VS will have a broken dependency tree, right?

Yes, using this SDK with older VS versions will break. Submitted dotnet/toolset#4542 with the update.

Let's remove the ReportAssetsLogMessages task.

Removed in f868606. Please review.

I think the TargetDefinitions, FileDefinitions, and FileDependencies may be used by some of our build infrastructure (in dotnet/installer, for example). However, I would propose that by default we don't produce them, with a flag that can be used to turn them back on.

Added flag EmitLegacyAssetsFileItems in the most recent commit, but it's causing test failures in CI and I cannot get tests to run locally. I'll pick this up tomorrow, but any guidance would be appreciated. Or we can split those changes out into a follow up PR.

drewnoakes added 14 commits May 12, 2020 10:39
From now on, this task will only return top-level items, so we do not
need to output assemblies, nor do we need to accept FileDefinitions.
…nTime

Performance work on the Dependencies node in dotnet/project-system mean
that only top-level package data is needed from the design-time build.

This commit removes items and metadata related to transitive
dependencies and hierarchy.

- Remove metadata Dependencies, which used to list child IDs
- Remove metadata IsTopLevelDependency, which is now implicitly true
- Remove 'target' items
- Remove object cloning, now that instances are immutable
Previously PreprocessPackageDependenciesDesignTime returned package
dependencies for all targets, and PackageRuleHandler in the project
system would filter based on TargetFrameworkMoniker.

This change applies the filtering in this task instead.

As part of this change we are now able to remove the target prefix from
the item spec of output items. This reduces string allocation, improves
the chance of pooling and reduces string manipulation by the consumer.
This metadata always has 'true' as its value. We can infer this in the
project system.
This metadata always has 'Package' as its value. We can infer this in
the project system.
Since VS 16.7, design-time builds no longer consume assets file
diagnostics as items. This commit removes their generation and
supporting code.
From VS 16.7 onwards, the DTB no longer requires items of type
`TargetDefinitions`, `FileDefinitions`, `FileDependencies`.

This commit stops producing them by default. To restore the previous
behaviour, set the `EmitLegacyAssetsFileItems` property to `true`.
@drewnoakes drewnoakes force-pushed the design-time-package-references branch from 17c60d0 to 28e7900 Compare May 12, 2020 02:01
@drewnoakes
Copy link
Member Author

Fixed test failures and believe this is good to merge.

Please review f868606, 28e7900 and dotnet/toolset#4542.

Co-authored-by: Daniel Plaisted <[email protected]>
@drewnoakes drewnoakes merged commit b9874ce into dotnet:release/3.1.4xx May 13, 2020
@drewnoakes drewnoakes deleted the design-time-package-references branch May 13, 2020 08:08
dsplaisted added a commit to dotnet/cli that referenced this pull request May 19, 2020
After dotnet/sdk#11358, EmitLegacyAssetsFileItems needs to be set to true in order to generate FileDefinitions items.
dotnet-maestro bot added a commit to dotnet/cli that referenced this pull request May 19, 2020
* Update dependencies from https://github.com/dotnet/sdk build 20200513.9

Microsoft.NET.Sdk
 From Version 3.1.400-preview.20263.1 -> To Version 3.1.400-preview.20263.9

* Update stage 0

* Stage 0 update for LKG version

* Bump MSBuild version to 16.7

* Update NuGet clien version to 6609

* Fix deployment of hostfxr for SDK Resolver

After dotnet/sdk#11358, EmitLegacyAssetsFileItems needs to be set to true in order to generate FileDefinitions items.

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Jacques Eloff <[email protected]>
Co-authored-by: Rainer Sigwald <[email protected]>
Co-authored-by: Daniel Plaisted <[email protected]>
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.

3 participants