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

use MSBuild binlog to report dependencies #10597

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

brettfo
Copy link
Contributor

@brettfo brettfo commented Sep 12, 2024

This PR contains a temporary commit to redirect the smoke tests. That commit will have to be removed prior to merging.

This PR has a corresponding smoke test PR that will hav to be merged at the same time: dependabot/smoke-tests#227

Previously, a temporary project was created to try and determine a project's full set of dependencies. This wasn't always 100% accurate and could be slow due to all of the file copying.

This PR instead invokes MSBuild directly against the relevant project and produces a binary log (.binlog) that is then analyzed to get the full set of dependencies.

One of the benefits to this approach is that any give package can be directly associated with its parent project and MSBuild handles all of the complex property evaluation that might occur.

There are two main differences in behavior:

  1. Properties are now fully evaluated; we no longer return $(SomePackageVersion); we know exactly what was resolved.
  2. We no longer report Directory.Packages.props as the source of a dependency. While the dependency version might be found there, the dependency really lies with the project file. This has no effect on actually performing the update; that occurs just like before.

Another relatively minor side effect is that we no longer report NETStandard.Library as a dependency; it's explicitly excluded. While it is a NuGet package that gets resolved, it's not one that can be directly updated so it is simply no longer reported.

The vast majority of the changes in this PR are to tests.

The primary file to review is SdkProjectDiscovery.cs; that's where the dependency analysis was completely migrated to the binary log.

@brettfo brettfo added the L: dotnet:nuget NuGet packages via nuget or dotnet label Sep 12, 2024
@brettfo brettfo force-pushed the dev/brettfo/nuget-report-dependencies branch 2 times, most recently from 1edef09 to eaa3f30 Compare September 16, 2024 18:22
@@ -20,6 +20,7 @@ tab_width = 4

# New line preferences
insert_final_newline = true
#end_of_line = lf
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have my local environment set to always check out with LF so adding this makes it easy for me to dotnet format.

@brettfo brettfo force-pushed the dev/brettfo/nuget-report-dependencies branch 3 times, most recently from 5b8d751 to cccbcf2 Compare September 17, 2024 23:09
@brettfo brettfo force-pushed the dev/brettfo/nuget-report-dependencies branch from cccbcf2 to 60c6971 Compare September 17, 2024 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: dotnet:nuget NuGet packages via nuget or dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant